0

Jquery Code which check the internet/network is there or not(mobile/PC/Tablet).It must just check on page load.I thinkAjax will good because Ajax will check after certain interval.

I am looking just like http://tomriley.net/, But it is plugin, I am looking for simple jquery/Javascript.

Its static page which check system internet only.

Any idea is appreciated.

Mike Phils
  • 3,475
  • 5
  • 24
  • 45

1 Answers1

1

You might try a $.ajax() invoication with a .fail() handler, for example JQuery's getJSON():

var network_available;         // bool
var url = '/some/json/call';   // must be relative to the site that 
                               // you are already addressing

$.getJSON(url, function(data) {
    network_available = true;
})
.fail(function() {
    network_available = false;
});

Though I doubt this will solve all of your problems. The Javascript engine won't allow 'foreign' URL's, just the domain that the script or page was received from. So you'd not be really testing network availability, but also whether your site is up and responding within a reasonable time.

Karel Kubat
  • 1,635
  • 11
  • 12