title: Why is return not working in getJSON and why cant I write into variable from getJSON?
body: <p>I have a function which uses <code>getJSON</code> but its not working like I expected.</p>
  
  <pre><code>function balbla(name, param) {
          $.getJSON("/blabla.json?name=" + name + "&amp;param=" + param, function(data) {
                  return data.bla;
          });
  }
  </code></pre>
  
  <p>When I use <code>alert(data.bla)</code> in the getJSON method it works but when I try <code>return data.bla</code> it doesnt. Also when I create a variable and try to write the value of <code>data.bla</code> to it it simply doesnt work!</p>
  
  <p>// I tried this:</p>
  
  <pre><code>function getRouteData(name, param) {
      return $.getJSON('/routes_js.json', {route:name, opt: param});
  }
  function getRoute(name, param) {
          getRouteData(name, param).done(function(data) {
                  return data.route;
          });
  }
  </code></pre>
  
  <p>But when I call <code>getRoute("bla", "blub")</code> it still returns <code>undefined</code>.</p>