title: How to return a value from a function that calls $.getJSON?
body: <pre><code>function lookupRemote(searchTerm)
  {
     var defaultReturnValue = 1010;
     var returnValue = defaultReturnValue;
  
     $.getJSON(remote, function(data)
     {
        if (data != null)
        {
             $.each(data.items, function(i, item)
             {
                 returnValue = item.libraryOfCongressNumber;
             });
        }
      });
      return returnValue;
  }
  </code></pre>
  
  <p>Why is the <code>returnValue</code> from this function alway equal to the default value set at the beginning of the function and never to the value retrieved from the JSON lookup?</p>