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.
I currently have this code as the onreadystatechange function:
if(xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
element(id).innerHTML = "Online";
}
else {
element(id).innerHTML = "Offline";
}
}
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?
Any suggestions for how to capture an AJAX request to an offline website?