title: How to detect timeout on an AJAX (XmlHttpRequest) call in the browser?
body: <p>I'm looking on the web, but documentation is hard to come by.  We all know the basic AJAX call using the browser's built-in <code>XMLHttpRequest</code> object (assume a modern browser here):</p>
  
  <pre><code>var xmlHttp = new XMLHttpRequest();  // Assumes native object
  
  xmlHttp.open("GET", "http://www.example.com", false);
  
  xmlHttp.send("");
  
  var statusCode = xmlHttp.status;
  // Process it, and I'd love to know if the request timed out
  </code></pre>
  
  <p>So, is there a way that I can detect that the AJAX call timed out by inspecting the XMLHttpRequest object in the browser?  Would I be advised to do something like <code>window.setTimeout(function() { xmlHttp.abort() }, 30000);</code>?</p>
  
  <p>Thanks!</p>
  
  <p>-Mike</p>