function loadjs(filename) { $.getScript("https://"+UMBRELLA.stat+"/v4/"+filename).done(function(data, textStatus, jqxhr){ return true; }); } 

How do I get loadjs to return true after the file via getScript is loaded. In the code above, I wanted return true; was for loadjs ()

Thank you in advance for your advice!

Reported as a duplicate by Grundy members, Duck Learns to Hide , sercxjo , αλεχολυτ , aleksandr barakin 3 Sep '16 at 6:49 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    Since you want, you can not do.

    But you can do a little differently:

    You need to perform some action at the end of the download. You can push it into the loadjs function as parameters. It will look something like this:

     function loadjs(filename, callback, scope) { $.getScript("https://"+UMBRELLA.stat+"/v4/"+filename).done(function(data, textStatus, jqxhr){ if (callback != undefined){ if (scope != undefined) { callback.call(scope, true); } else { callback(true); } } }); } 

    And the calling function might look like this:

     //... var f = function (isLoaded) { if (isLoaded === true) { // ваши дальнейшие действия после загрузки скрипта } }; loadjs("http://mysite/myfile.js", f, this); //... 

    Upon completion of the download, the function f will be called in the environment where it is located (this link, see the info about the "call").