title: Doing an AJAX request to a website that might be up, or might be down
body: <p>I'm writing a small app that will be used to monitor the status of a few websites, mainly just to report which websites are online and which websites are offline.</p>
  
  <p>I currently have this code as the <em>onreadystatechange</em> function:</p>
  
  <pre><code>if(xmlhttp.readyState == 4) {
      if (xmlhttp.status == 200) {
          element(id).innerHTML = "Online";
      }
      else {
          element(id).innerHTML = "Offline";
      }
  }
  </code></pre>
  
  <p>It runs properly when the website is online, but it never reaches the 'else' block if I do an AJAX request on a website that is offline.. I'm thinking the request never reaches readyState 4 if the website is down?</p>
  
  <p>Any suggestions for how to capture an AJAX request to an offline website?</p>