开发者

Check Active Internet Connection [duplicate]

This question already has answers here: 开发者_StackOverflow Detect the Internet connection is offline? (22 answers) Closed 1 year ago.

Obviously this is a Javascript problem. As javascript are already loaded to the server, I was wondering if there is way to check whether there is active internet connection or not.


You could send an ajax request and see if it gets a response.
With jQuery:

$.ajax({
  url: 'ajax/test.html',
  success: function(data) {
    alert('Connection.');
  },
  error: function(data) {
    alert('No Connection.');
  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜