I am doing an AJAX request. In my onFail
event of the Request
I catch the XHR
object.
just console.info this
in the callback onFailure
- this.status
contains the http error response. this.xhr
contains more about the request and extended responses.
http://www.jsfiddle.net/dimitar/NF2jz/365/
new Request({
url: '/secho/html/',
data: {
html: "<p>Text echoed back to request</p>" + "<script type='text/javascript'>$('target').highlight();<\/script>",
delay: 3
},
method: 'post',
onFailure: function() {
var error = "Error " + this.status;
switch (this.status) {
case 404:
error = "Document not found (404)";
break;
case 301:
error = "Object moved permanently (301 redirect)";
break;
case 302:
error = "Object moved temporarliy (302 redirect)";
break;
}
alert(error);
}
}).send();
精彩评论