title: JSON Parse File Path
body: <p>I'm stuck trying to get the correct path to the local file. I have the following directories:</p>
  
  <pre><code>Resources -&gt;
     data -&gt;
         file.json
     js -&gt;
       folder -&gt;
          script.js
     html -&gt;
        folder -&gt;
           file1.html
  </code></pre>
  
  <p>I'm executing <code>script.js</code> from <code>file1.html</code>, with js code:</p>
  
  <pre><code>var answers = JSON.parse('../../data/file.json');
  alert(answers);
  </code></pre>
  
  <p>But it doesn't work, even alert is not starting.
  What is wrong?</p>
  
  <p>Also I've tried this:</p>
  
  <pre><code>function readJSON(file) {
      var request = new XMLHttpRequest();
      request.open('GET', file, false);
      request.send(null);
      if (request.status == 200)
          return request.responseText;
  };
  
  var temp = readJSON('../../data/file.json');
  alert(temp);
  </code></pre>
  
  <p>Alert undefined in this case.</p>