tags:

views:

64

answers:

3

I call the load method. There are some occasions 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);
+4  A: 

Pass in a callback function:

$("#section-main-wrapper").load(uri, null, function(response, status, xhr) {
    // Check status
});
Richard Szalay
cool, thanks :)
frosty
+1  A: 

http://docs.jquery.com/Ajax/load

$(...).load(url, null, function (responseText, textStatus, XMLHttpRequest) cb {
  this; // dom element
});
Ondra Žižka
+1  A: 
$.ajax({
  url: uri,
  cache: false,
  success: function(html){
    $("#section-main-wrapper").replaceWith(html);
  },

  error: function (XMLHttpRequest, textStatus, errorThrown) {
    // Do something here
    this; 
  }  
});
jpartogi