向Google发送ajax请求,以确保计算机已连接到互联网

Send ajax request to Google to make sure that the computer is connected to the Internet

本文关键字:计算机 连接 互联网 确保 发送 Google ajax 请求      更新时间:2023-09-26

检查我的互联网连接,我使用以下代码:

function send(){
    $('input').ajaxError(function(){
    alert("failed");
    });
    $.get('http://www.google.com', function(data) {
    alert("success");
    });
}

我称这个函数为

    input type="button" value="Click to report" onclick="sent()"

你应该使用你写的代码,但不是使用google,而是使用"/"(你自己的域名,默认页面)。这不应该失败。