如何在jquery中返回404状态
问题描述:
我调用load方法。有时它所调用的页面不存在。在萤火虫我可以看到404状态被返回。我如何在jQuery中访问这个状态,这样我就可以处理它了?如何在jquery中返回404状态
$("#section-main-wrapper").load(uri);
答
传递一个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;
}
});
冷静,谢谢:) – frosty 2010-01-14 13:22:28