title: How to set up ajax time out?
body: <p>I have this code to time out ajax call after 40 secs:</p>
  
  <pre><code>if (xmlhttp) {
      xmlhttp.open("GET", MY_SERVLET, true);              xmlhttp.onreadystatechange = showResults;               
      xmlhttp.send(null);
      var httpTimeOut=setTimeout("ajaxTimeout();",40000);
              }
  
          function ajaxTimeout() {
              xmlhttp.abort();
          document.getElementById('errorShow').innerHTML = "Request Timed out";
              }
  </code></pre>
  
  <p>However I am unable to test this due to environment constraints at my place. Can anyone please tell if this is correct or any modifications are required??</p>