title: Better way to pass variable from child to parent function javascript
body: <p>For example</p>
  
  <pre><code>function getResult(field) {
      $.ajaxSetup ({cache: false, async: false});
      $.get("api.php?field="+field, function(i) {
          result = i;
      });
      return result;
  };
  </code></pre>
  
  <p>The problem with this is that result becomes global.  If I do <code>var result = i;</code> then the parent function (getResult) cannot see the variable <code>result</code>.</p>
  
  <p>Is there a clever way to do this?</p>
  
  <p>The code that I have posted works correctly. I have set my AJAX calls to be done synchronously.</p>