DaveEverFade Posted June 13, 2007 Share Posted June 13, 2007 Does anyone know if there is a way of checking if the response from an ajax request is a valid page? To explain more: I have a site that uses ajax heavily for multiple refreshes for example, a msn style shoutbox. This is my stateChanged function function stateChanged(Div) { //alert(request.readyState) if(request.readyState<4) { window.status="Loading"; document.body.style.cursor = 'wait'; } if (request.readyState==4 || request.readyState=="complete") { document.getElementById(Div).innerHTML=request.responseText window.status="Done"; document.body.style.cursor = 'auto'; } } Now what i want to be able to do is identify if the page cannot be displayed (but I don't mean a 404 error or such like). I mean if the server has gone down or something because if that is the case I get a hideous "Web Server Temporarily Unavailable" displayed where my page should be. Any ideas? ??? Link to comment https://forums.phpfreaks.com/topic/55406-web-server-temporarily-unavailable-status/ Share on other sites More sharing options...
softnmedia Posted June 15, 2007 Share Posted June 15, 2007 You can do it by checking the status. if (http_request.readyState == 4) { if (http_request.status == 200) { } else { alert('There was a problem with the request.'); } Link to comment https://forums.phpfreaks.com/topic/55406-web-server-temporarily-unavailable-status/#findComment-275268 Share on other sites More sharing options...
DaveEverFade Posted June 22, 2007 Author Share Posted June 22, 2007 Ta! I totally forgot about the http_request.status duh! Many thanks Link to comment https://forums.phpfreaks.com/topic/55406-web-server-temporarily-unavailable-status/#findComment-280113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.