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...
Since the Ajax applications communicate with the Hub via the server, you cannot operate the Hub via applications in the case of Internet connection failure.
jQuery provides several methods for AJAX functionality. With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post - And you can load the external data directly into the selected HTML elements of your web page!
No you do not need the internet connection when writing codes in jQuery. Download the jQuery file, keep it on the website folder and then include it on your page. In case if you are putting the jQuery CDN link in your website only then you will need internet connection.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With