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? ??? Quote Link to comment 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.'); } Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.