每 X 分钟调用一次 jQuery Ajax 请求 [英] Call jQuery Ajax Request Each X Minutes
本文介绍了每 X 分钟调用一次 jQuery Ajax 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在特定时间段内调用 Ajax 请求?我应该使用 Timer Plugin 还是 jQuery 有这个插件?
How can I call an Ajax Request in a specific time Period? Should I use Timer Plugin or does jQuery have a plugin for this?
推荐答案
您可以使用内置的 javascript setInterval.
You can use the built-in javascript setInterval.
var ajax_call = function() {
//your jQuery ajax code
};
var interval = 1000 * 60 * X; // where X is your every X minutes
setInterval(ajax_call, interval);
或者如果你是更简洁的类型......
or if you are the more terse type ...
setInterval(function() {
//your jQuery ajax code
}, 1000 * 60 * X); // where X is your every X minutes
这篇关于每 X 分钟调用一次 jQuery Ajax 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文