开发者

Check Active Internet Connection [duplicate]

开发者 https://www.devze.com 2023-02-03 09:02 出处:网络
This question already has answers here: 开发者_StackOverflow Detect the Internet connection is offline?
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

精彩评论

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

关注公众号