I faced a problem. I wrote my jquery component like below:
(function ( $ ) {
$.fn.addSocialShare = function() {
this.append(getButtonHTML());
return this;
};
var getButtonHTML = function(){
var html;
$.get('myUrl', function(data){
html = data; // data is defined, request ok
})
return html;
}
})( jQuery );
The problem is that html
variable is not defined when I return it. How I can fix it? Where is my mistake?