title: Read local text file with javascript
body: <p>I want to read a local text file from my local html file, so I tried to follow the solution in this thread <a href="https://stackoverflow.com/questions/14446447/javascript-read-local-text-file">Javascript - read local text file</a> but the suggested solution does not work for me either:</p>
  
  <pre><code>function readTextFile(file)
  {
      var rawFile = new XMLHttpRequest();
      rawFile.open("GET", file, false);
      rawFile.onreadystatechange = function ()
      {
          if(rawFile.readyState === 4)
          {
              if(rawFile.status === 200 || rawFile.status == 0)
              {
                  var allText = rawFile.responseText;
                  alert(allText);
              }
          }
      }
      rawFile.send(null);
  }
  </code></pre>
  
  <p>When I call the function <code>readTextFile("file:///D:/test/text.txt");</code> no error does show up in firebug but no alert is shown neither. I use Windows und Firefox 51.0.1 (64-Bit).
  I don't want to use the function <code>FileReader()</code> in combination with a button <code>&lt;input type='file' onchange='openFile(event)' ...</code> since the text file needs to be read automatically when loading the page. So how can I make work the solution above?</p>
  
  <p>Reading the thread linked it looks like others also have problems with that solution although the thread is marked as solved.</p>