title: Return $.get data in a function using jQuery
body: <p>I'm trying to call a function that contains jQuery code. I want this function to return the results of the jQuery statement. It is not working, and I'm trying to figure out why.</p>
  
  <pre><code>function showGetResult (name) {
      var scriptURL = "somefile.php?name=" + name;
      return $.get(scriptURL, {}, function(data) { return data; });
  }
  
  alert (showGetResult("John"));
  </code></pre>
  
  <p>The alert displays "<code>[object XMLHttpRequest]</code>." However, if I run the jQuery statement by itself, outside of a function, it works fine -> <code>$.get(scriptURL, {}, function(data) { alert(data); })</code></p>
  
  <p>I'd like to be able to re-use this code by putting it inside of a function that returns the <code>$.get</code> data. What fundamental mistake am I making here?</p>