Is it possible/do web applications developers ever purposely set/send out a HTTP Status Code, so that it can be better hanled client side by pages utilizing ajax?
Yea, for example error handling, you might handle an exception in your backend code which your javascript doesn't have full visibility of, therefore with your exception you might also send a status code, so that the javascript can be,
Code:
if (xmlhttp.status == mystatus)
{
document.findelementbyid("foo").value="there has been some error";
}
It seems sensible, but I don't know if it can be done, or if anyone does it, or if there is any need to.
Well, why don't you build a simple AJAX object, and try to set the status. Personally, I don't really find use for it because the status applies to the server page status. Why would you need more than...
Code:
if (objXML.status == 200) {alert("Page found.");}
...
else if (objXML.status == 403) {alert("Access denied.");}
else if (objXML.status == 404) {alert("URL not found.");}
...
else {alert("status is " + request.status);}
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Bookmarks