我想用setTimeout每10秒重复一次函数。我的功能是:我的setTimeout不尊重延迟
dateInLive = function() {
crono = function(){
setTimeout(function() {
$('.datePoste').each(function(){
$(this).load('in_live.php','in_live='+$(this).attr('id'))
});
crono();
}
,10000);
}
crono();
}
但是,它确实是随机的;有时在15s之后重复,有时在3s之后,有时在6s之后。
它看起来像你不小心叫了两次crono()。尝试从setTimeout中删除crono()调用? – lifetimes 2013-03-26 15:51:06
看起来你可以使用'setInterval()'而不是'setTimeout()'来获得更多的好处。 – 2013-03-26 15:51:36
@ user125697不,他在'setTimeout()'中调用它来重复该函数。相反,最好使用'setInteral()'。 – Antony 2013-03-26 15:51:37