title: Javascript wait for function response
body: <p>I have the following code:</p>
  
  <pre><code>myFunc();
  bar();
  </code></pre>
  
  <p>myFunc() is making an ajax request</p>
  
  <p>I don't want to execute bar() until myFunc()'s request has completed.</p>
  
  <p>I also do not want to move the call to bar() inside of myFunc.</p>
  
  <p>possible?</p>
  
  <p><em>EDIT</em></p>
  
  <p>Here is the code I ended up with:</p>
  
  <pre><code>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.. }
  
  };
  </code></pre>