title: How to return value from $.getJSON
body: <p>I'm having a problem with method using $.getJSON. It's very simple and it looks like that:</p>
  
  <pre><code>function lastID(query) {
  
    $.getJSON(url+query ,function(json){
  
      var type_id = json.data;
  
  });
  
      return type_id // doesn't work
  }
  </code></pre>
  
  <p>Could you please tell me how to return type_id to some other value for instance like this:</p>
  
  <pre><code>var returnedID = lastID(query); // this schould me equal to returned type_id from lastID method.
  </code></pre>
  
  <p>Many thanks for your reply</p>