title: How do I load a local JSON file in a cordova app?
body: <p>I have a question on how to load an local JSON file via an httpxmlRequest with pure JavaScript in a Cordova app.</p>
  
  <p>I found out myself that it must have to do something with the file extension, since loading the file with an ".html" extension loads perfectly fine.</p>
  
  <pre><code>var filepath = "data/test.json";
  var obj;
  var hr = new XMLHttpRequest();
  hr.open("POST", filepath, true);
  hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  hr.onreadystatechange = function () {
      if (hr.readyState == 4 &amp;&amp; hr.status == 200) {
          var res = hr.responseText;
          console.log("Response: " + res);
          obj = JSON.parse(res);
      }
  };
  
  // Send to server
  hr.send("");
  </code></pre>
  
  <p>test.json:</p>
  
  <pre><code>{
    "price": 5,
    "time": "00:00"
  }
  </code></pre>
  
  <p>test.html:</p>
  
  <pre><code>{
    "price": 5,
    "time": "00:00"
  }
  </code></pre>
  
  <p>This code runs fine if the filepath ends with an file extension of ".html", but when changing it to ".json" it breaks and throws an 404 file not found error.</p>