title: Get JSON data from a file using (JavaScript)
body: <p>I need to know how can I get json data using JavaScript without using Jquery. I just want to know how to get data only using JavaScript. </p>
  
  <p>My Json file. </p>
  
  <pre><code>{"JsonProjectIDResult":[{"_capacity":15,"_description":"Meeting Room","_dev_default_view":3,"_deviceID":1,"_deviceName":"MobiTech","_deviceTypeID":1,"_projectID":1,"_roomID":2,"_roomName":"Room2","_room_admin_mail":null}]}
  </code></pre>
  
  <p>My home.html file </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;JavaScript Get Json&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;My Home Page&lt;/h1&gt;
  
  &lt;div id="results"&gt;
      &lt;!-- Display Jason Data --&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  
      var resultDiv = document.getElementById("results");
  
      var newsURL = "http://localhost:81/testjs/data.json";
  
      var e;
  
      if (window.XMLHttpRequest) {
          // code for IE7+, Firefox, Chrome, Opera, Safari
          e = new XMLHttpRequest();
      } else {
          // code for IE6, IE5
          e = new ActiveXObject("Microsoft.XMLHTTP");
      }
  
      e.onreadystatechange = function() {
  
          var html = " ";
  
          if (e.readyState == 4 &amp;&amp; e.status == 200) {
              response = JSON.parse(e.responseText);
  
              if(typeof(e.responseText)==="string") {
                  d = e.responseText;
              } else {
                  if (typeof(e.responseXML)==="object") {
                      d = e.responseXML;
                  };
              }
  
              var myData = response['JsonProjectIDResult'];
  
              //Print results 
              html  = myData[0]._capacity+"&lt;br /&gt;";
              html += myData[0]._description+"&lt;br /&gt;";
              html += myData[0]._dev_default_view+"&lt;br /&gt;";
              html += myData[0]._deviceID+"&lt;br /&gt;";
              html += myData[0]._deviceName+"&lt;br /&gt;";
              html += myData[0]._deviceTypeID+"&lt;br /&gt;"; 
              html += myData[0]._projectID+"&lt;br /&gt;"; 
              html += myData[0]._roomID+"&lt;br /&gt;"; 
              html += myData[0]._roomName+"&lt;br /&gt;"; 
              html += myData[0]._room_admin_mail+"&lt;br /&gt;";
  
              resultDiv.innerHTML = html;
          }
      };
  
      e.open("GET", newsURL, true);
      e.send();
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>After my friends gave me some helpful answer I wondered my code like this. It's working. Now I need to run this as a loop. When every records display using a loop. Can I do it in JavaScript.</p>