Please see example below. How do I call my function from within the loaded file?
Here is my external file, loaded with ajax:
// some-file-name.js
var api = {
method1: function() {
// doStuff here
}
}
Here I am loading the file and hopefully invoking some function from the new methods provided:
// load script and do stuff with it when done
$.when(
$.getScript("some-file-name.js"),
$.Deferred(function(deferred) {
$(deferred.resolve);
})).done(function() {
// how to call api.method1() when api.method1() gives me undefined?
});
Any suggestions much appreciated.