It's a little hack, but ..
You can declare a variable inside loadable scripts and check it after you have loaded the script (provided that the full function is still working):
script_test.js:
var script_test = true;
And then:
$.getScript("script_test.js", function () { if (typeof script_test !== undefined) alert("script has been loaded!"); });
Or you could just try and see if there is something in your script that actually exists - functions, variables, objects, etc.
A more general way to do this is to add a self-executing function inside the scripts you want to load and make them execute the function in your "main" script:
main_script.js:
function scriptLoaded(scriptName) { alert(scriptName + " loaded!"); } $.getScript("script_test.js");
script_test.js:
(function () { scriptLoaded("script_test.js"); })();
roosteronacid
source share