非常简单的任务,每10秒刷新一次div:
function upd(){
alert('asd');
$('#maincontent').load('providerpage.php?allimages=1 #maincontent > *');
}
window.onload=function(){
setTimeout('upd()',10000);
}
但是上面的代码不起作用,伙计们请告诉我,它有什么问题?我为测试设置了警报,但在第一次迭代时,它只显示了一次。
As stated by Juhana and others in the comments:
That's what
setTimeout()
does, runs the function once. You probably wantsetInterval()
I don't know why no one put that as an answer (instead of a comment) so he can accept the answer, and we all leave this question alone (instead of posting closing votes).
Zheka: you can also put the answer yourself once you know the solution if no one else does.