title: Load local JSON file into variable
body: <p>I'm trying to load a .json file into a variable in javascript, but I can't get it to work. It's probably just a minor error but I can't find it.</p>
  
  <p>Everything works just fine when I use static data like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>var json = {
    id: "whatever",
    name: "start",
    children: [{
        "id": "0.9685",
        "name": " contents:queue"
      }, {
        "id": "0.79281",
        "name": " contents:mqq_error"
      }
    }]
  }
  </code></pre>
  
  <p>I put everything that's in the <code>{}</code> in a <code>content.json</code> file and tried to load that into a local JavaScript variable as explained here: <a href="https://stackoverflow.com/questions/2177548/load-json-into-variable">load json into variable</a>.</p>
  
  <pre class="lang-js prettyprint-override"><code>var json = (function() {
    var json = null;
    $.ajax({
      'async': false,
      'global': false,
      'url': "/content.json",
      'dataType': "json",
      'success': function(data) {
        json = data;
      }
    });
    return json;
  })();
  </code></pre>
  
  <p>I ran it with the Chrome debugger and it always tells me that the value of the variable <code>json</code> is <code>null</code>. The <code>content.json</code> file resides in the same directory as the .js file that calls it.</p>
  
  <p>What did I miss?</p>