I call the load method. There are some occa开发者_开发技巧sions when the page it calls does not exist. In firebug I can see the 404 status is returned. How can I access this status in jQuery so I can handle it?
$("#section-main-wrapper").load(uri);
Pass in a callback function:
$("#section-main-wrapper").load(uri, null, function(response, status, xhr) {
// Check status
});
http://docs.jquery.com/Ajax/load
$(...).load(url, null, function (responseText, textStatus, XMLHttpRequest) cb {
this; // dom element
});
$.ajax({
url: uri,
cache: false,
success: function(html){
$("#section-main-wrapper").replaceWith(html);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// Do something here
this;
}
});
精彩评论