我調用load方法。有時它所調用的頁面不存在。在螢火蟲我可以看到404狀態被返回。我如何在jQuery中訪問這個狀態,這樣我就可以處理它了?如何在jquery中返回404狀態
$("#section-main-wrapper").load(uri);
我調用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