实施"这是太长"使用jQuery消息 [英] Implementing "this is taking too long" message with jQuery
本文介绍了实施"这是太长"使用jQuery消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何实现一个Gmail样这样花费的时间太长警告消息使用 jQuery的AJAX API ?
How to implement a gmail-like "this is taking too long" warning message using jQuery Ajax API?
对于那些谁从来没有见过在Gmail的这个消息,看来当签署过程耗时过长完成,然后一些解决方案提出了建议。
For those who have never seen this message on gmail, it appears when the 'signing in' process takes too long for completion, and then some solutions are suggested.
我使用jQuery的Ajax在我的网站,我想提醒用户,当网页加载速度很慢,然后提出了一些解决方案(链接刷新页面,或一个帮助页面,例如)。
I'm using jQuery Ajax on my website and I want to warn users when page loading is very slow and then suggest some solutions (a link to refresh the page, or to a help page, for example).
推荐答案
我会建议一些简单的排列如下:
I'd suggest something as simple as this arrangement:
function tooLong() {
// What should we do when something's taking too long? Perhaps show a `<div>` with some instructions?
$("#this-is-taking-too-long").show();
}
// Then, when you're about to perform an action:
function performSomeAction() {
var timer = setTimeout(tooLong, 10000);
$.get('/foo/bar.php', {}, function() {
// Success!
clearTimeout(timer);
});
}
这篇关于实施&QUOT;这是太长&QUOT;使用jQuery消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文