title: Trying to store value of jquery callback, but code is running out of sequence
body: <p>I have some code that does this:</p>
  
  <pre><code>function A(){
      $.ajax({
          ...blah blah...
          success: function(data){
              return data;
      });
   }
  </code></pre>
  
  <p>and then I'm trying to use the data later:</p>
  
  <pre><code>var x = A();
  x.doSomething();
  </code></pre>
  
  <p>but x is never stored, since A() takes a while.  Is there any way to avoid this?</p>