2016-07-22 43 views
-2

我需要显示一些消息,刷新页面或稍后重试,如果有一个服务器的通信问题,没有互联网连接,或Ajax请求没有回应等等。我可以在控制台上找到所有这些错误消息。我如何触发这些消息?如何在发生错误显示消息(说没有互联网连接)的jQuery

这样的事情。谷歌的Gmail也有类似的东西。

enter image description here

+1

你读过的'$。阿贾克斯()'函数的文档? – nnnnnn

+0

的可能的复制[检查与jQuery互联网连接(http://stackoverflow.com/questions/20043215/check-internet-connectivity-with-jquery) –

回答

1

退房Check Internet connectivity with jquery

在代码

check_connectivity.is_internet_connected().done(function() { 
    //The resource is accessible - you are **probably** online. 
}).fail(function(jqXHR, textStatus, errorThrown) { 
    alert(0,"oops","No Internet Connection"); 
}); 

当然,你可以用任何你想要的造型取代alert()并显示它是这样的这一部分。

相关问题