How to display a message if error occurs (say no internet connection) jQuery

1.3k Views Asked by At

I need to display some message to refresh the page or try again later if there is a server communication problem, no internet connection, or ajax request did not respond, etc. And I can find all theses error messages on the console. How can I trigger a message for these?

something like this. Google's Gmail have also something similar.

enter image description here

1

There are 1 best solutions below

0
On

Check out Check Internet connectivity with jquery

In this part of the code

check_connectivity.is_internet_connected().done(function() {
    //The resource is accessible - you are **probably** online.
}).fail(function(jqXHR, textStatus, errorThrown) {
    alert(0,"oops","No Internet Connection");
});

Of course you can replace alert() with whatever styling you want and display it as such.