I have the code snippet below:
myFunc();
bar();
The function myFunc() initiates an ajax request.
I want to ensure that bar() is only executed after myFunc()'s ajax request has been completed.
However, I do not wish to move the call to bar() inside of myFunc.
Is this possible?
EDIT
Below is the revised code that addresses this issue:
var FOO = {
init: function(blah)
{
// Callback functions to be passed when loading challenge data via AJAX
var callbacks = {
myFunc1: function(){ myFunc1(blah); },
myFunc2: function(){ myFunc2(blah); },
};
this.bar(callbacks); // Load challenge data and set up the game
},
bar: function(callbacks) { ..iterate through and execute them.. }
};