I have the following code:
myFunc();
bar();
myFunc() is making an ajax request
I don’t want to execute bar() until myFunc()’s request has completed.
I also do not want to move the call to bar() inside of myFunc.
possible?
EDIT
Here is the code I ended up with:
var FOO = {
init: function(blah)
{
// Callbacks to pass to the AJAX challenge data load
var callbacks = {
myFunc1: function(){ myFunc1(blah); },
myFunc2: function(){ myFunc2(blah); },
};
this.bar(callbacks); // Load the challenge data and setup the game
},
bar: function(callbacks) { ..loop through and execute them.. }
};
In order to do what you are looking for, you must find a way for bar() to communicate with myFunc().
When you say that you do not want to move the call to bar() inside myFunc() this can be interpreted in several ways.
For example, you could make bar() a parameter of myFunc()
I hope this will help you
Jerome Wagner