title: Javascript read text file issue
body: <p>I have a text file ("sample.txt") residing on a server, the content of which changes at random intervals (anything from 250 ms to 10 seconds). The script below reads this text file every half a second and displays the text in the div element "cont" at the bottom. Everything works perfectly... except for the fact that approximately 10% of the time the text fails to display, even though 1) the text file contains text; 2) the request.readyState == 4; and 3) the request.status == 200. Can anybody shed any light on why this might be happening? Any help would be much appreciated.</p>
  
  <pre><code>&lt;body bgcolor=Black&gt;
  
  &lt;script type='text/JavaScript'&gt;
  
  var int=self.setInterval("getText()",500);
  
  function getText() {
     makerequest("sample.txt?v="+Math.random(),"cont");
     }
  
  function makerequest(serverPage, tagID) {
     var request = get_XmlHttp();
     request.open("GET", serverPage);
     request.send(null);
     request.onreadystatechange = function() {
     if (request.readyState == 4) {
        if (request.status == 200) {
           document.getElementById(tagID).innerHTML = request.responseText; }
        } 
     }
  }
  
  function get_XmlHttp() {
     var xmlHttp = null;
     if(window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
     }
     else if(window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     }
     return xmlHttp;
  }
  
  &lt;/script&gt;
  
  &lt;div id="cont"&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>