title: How to get data from local JSON using Ajax?
body: <p>Hello brilliant people!</p>
  
  <p>I've been sitting hours trying to figure out why I cant load a local JSON file using Ajax. I bet it's some silly typo, of that I totally misunderstand something. I'm using Node.js Express.</p>
  
  <p>The location of the two files:</p>
  
  <p><em>"trollytrains/views/trips.ejs"</em> (Doing the ajax-request)</p>
  
  <p><em>"trollytrains/json/allstops.json"</em></p>
  
  <pre><code>$.ajax(
      {
        type: "GET",
        url: "../json/allstops.json",
        contentType: "application/json; charset=utf-8",
        dataType: "json",     
        success: function (data) {
  
          alert('success');
  
        },
  
        error: function (msg) {
          alert("error");
          alert(msg.responseText);
        }
      });
  </code></pre>
  
  <p>I have tried altering the URL in all kinds of variations:</p>
  
  <p>./allstops.json</p>
  
  <p>allstops.json</p>
  
  <p>json/allstops</p>
  
  <p>/json/allstops</p>
  
  <p>/json.allstops.json</p>
  
  <p>No matter what I type I get a 404 error.</p>
  
  <pre><code>GET http://localhost:1337/json/allstops.json 404 (Not Found) jquery.min.js:4
  </code></pre>
  
  <p>Am I entering the wrong URL, or is there some other problem in my code that I haven't detected? I'm very new to JSON and Javascript so I wouln't be surprised.</p>
  
  <p>I'd really appreciate some tips!</p>
  
  <p>Best
  / J</p>