作者:黄金甲本人_553 | 来源:互联网 | 2023-01-30 19:16
这是我的代码:
setInterval(function() {
$.ajax({
type: "GET",
url: "someurl",
dataType: "json",
success: function(data) {
//Some code
}
});
}, 25 * 1000);
上面的代码每25秒调用一次ajax方法.但是我第一次需要它在10秒内调用它,然后每25秒调用一次.
所以我跟着这个
并将我的代码更改为以下内容:
setTimeout(function() {
setInterval(function() {
$.ajax({
type: "GET",
url: "someurl",
dataType: "json",
success: function(data) {
//Some code
}
});
}, 25 * 1000);
}, 10 * 1000);
但它似乎仍然没有奏效.
1> user94559..:
setTimeout(function() {
function doit() {
console.log("HERE");
}
doit(); // It's already been 10 seconds, so run it now
setInterval(doit, 25 * 1000); // Run it every 25 seconds from here on out
}, 10 * 1000);