title: Run code after function completes and get returned value
body: <p>Imagine i have a simple javascript function:</p>
  
  <pre><code>  function someFunction(integer)
    {
      data = integer + 1;
      return data;
    }
  </code></pre>
  
  <p>I need to call this from inside another function and use the returned value:</p>
  
  <pre><code>  function anotherFunction(integer)
    {
      int_plus_one = someFunction(integer);
      //Do something with the returned data...
      int_plus_two = int_plus_one + 1;
      return int_plus_two;
    }
  </code></pre>
  
  <p>How can i ensure that the return of anotherFunction return is only returned after someFunction completes? It actually seems to work ok with very fast functions like these. However if someFunction has to do some ajax lookups, the return of aotherFunction fails.</p>
  
  <p>Thanks,
  Steve</p>