ashok kumar

ashok kumar

  • NA
  • 89
  • 36k

How detect my internet connection without using navigator

Aug 26 2013 5:42 AM
Hi all,
        I need to detect whether Internet connection is there when my script loads, i used navigator.online it says" connection is there " if the PC in LAN and able to connect to internet, and also the path to my Gmap js files should load according the connection settings online and offline settings intially i tried

   $(document).ready(function () {
              $.ajax({
                  url: 'http://in.yahoo.com/',
                  success: function (data) {
                      alert('Connection.');
                  },
                  error: function (data) {
                      alert('No Connection.');
                  }
              });
          });

but this is also not working.

iam getting error like XMLHttpRequest cannot load http://in.yahoo.com/. Origin http://localhost:40624 is not allowed by Access-Control-Allow-Origin.

For which i added 

protected void Application_BeginRequest(object sender, EventArgs e) { HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); }
 in my Global.asax file

PLs suggest me i nearly spend a Day in searching,pls help me out


Answers (1)