开发者

how to return 404 status in jquery

开发者 https://www.devze.com 2022-12-17 11:37 出处:网络
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

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; 
  }  
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号