title: Trying to read a text file in javascript but keep getting status =0 and no text
body: <p>I'm trying to use JavaScript to read the contents of a text file.  The text file is in the root c drive folder.  XMLHttpRequest.status is returning 0 and no text.  What am I doing wrong?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script&gt;
      function readFile() {
          readTextFile("file:///C:/SafetyEvents.txt");
      }
  
          function readTextFile(file)
          {
               //alert("reading file: " + file);
               var rawFile = new XMLHttpRequest();
               rawFile.open("GET", file, true);
               //rawFile.send();
               rawFile.onreadystatechange = function ()  //not getting here
               {
                   alert("state " + rawFile.readyState);
               if(rawFile.readyState == 4)
                   {
                       if(rawFile.status == 0)
                   {
                       alert("status " + rawFile.status);
                       }
                       if(rawFile.status == 200 || rawFile.status == 0)
                       {
                           document.getElementById("fileContents").innerHTML = rawFile.responseText;
                   var allText = rawFile.responseText;
                           alert("text: " + allText);
                   document.getElementById("fileContents").innerHTML = allText
                           }
                       }
                   }
              }
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body onload="readFile()"&gt;
      &lt;h1&gt;Hello World!&lt;/h1&gt;
  
      &lt;p id="fileContents"&gt;&lt;/p&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>