Dialog box if there is no internet connection using jquery or ajax

ajax, dialog, internet-connection, javascript, jquery

Solution

In your JQuery ajax call, you could use the following and then query the status code of the error. Note that the status code will be 0 if they are offline, but you can also query other status codes (see below for a list):

$.ajax({
    //your ajax options
    error: function(statusCode, errorThrown) {
        if (statusCode.status == 0) {
            alert("you're offline");
        }
    }
});

Here's a list of status codes you could also catch for reference: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=40132

Problem

If there is no internet connection ,it will show some error message using dialog box like " No internet connection" without using java .I need to display using jquery or ajax script alert...

Original source

Related problems