-2

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

Hard Spocker
  • 765
  • 11
  • 32
  • 1
    Have you read the documentation for the `$.ajax()` function? – nnnnnn Jul 22 '16 at 07:05
  • Possible duplicate of [Check Internet connectivity with jquery](http://stackoverflow.com/questions/20043215/check-internet-connectivity-with-jquery) – Hard Spocker Jul 22 '16 at 08:45

1 Answers1

1

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.

Community
  • 1
  • 1
Cesar Bielich
  • 4,754
  • 9
  • 39
  • 81