views:

15

answers:

1

Yes, i have a normal ajax call that calls imback.php, that checks for new stuff if you have been blur for 50 sec.

Now if you disconnects from the internet, and when you get on focus, it will not be able to get imback.php.(i think its 404 error) So i would like to make a offline msg/timeout thing, so it alerts "You have no internet connection or something else went wrong".

How can i do that?

           $.ajax({
                url: 'imback.php', 
                success:function(msg) {
$('.NewStuffSinceActive').prepend(msg);

                }
            })
+1  A: 

You can use the error callback for this:

$.ajax({
  url: 'imback.php', 
  success: function(msg) {
    $('.NewStuffSinceActive').prepend(msg);
  },
  error: function(xhr, status, error) {
    alert("An error occured: " + error);
  }
})
Nick Craver