title: Read a JSON file using JavaScript
body: <p>I am using the Django framework for web-development. I want to read a JSON file and print its contents on a web-page.</p>
  
  <p><strong>Here's my script:</strong></p>
  
  <pre><code>&lt;script type="text/javascript"
          src = "file:///home/pragna/myproject/myapp/templates/myapp/segment2.json"&gt;
  &lt;/script&gt;
  
  &lt;script&gt;
      var mydata = JSON.parse(jsonstr);
      alert(mydata[0].text);
  &lt;/script&gt;  
  </code></pre>
  
  <p>I have stored my JSON file in the following format:</p>
  
  <pre><code>jsonstr = [
       {
           "text": "this is the text",
           "name" : "thisisme"
       },
  
       {
           "text": "some more text",
           "name" :"thisisaname"
       }
  ]
  </code></pre>
  
  <p>When I run the server, there is no 404 error when the the webpage requests the file, however, no alert comes up either.</p>