以时间间隔连续重复运行JavaScript函数 [英] Run a JavaScript function continuously repeating with a time interval
本文介绍了以时间间隔连续重复运行JavaScript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的第一个问题,我很感谢你很快回答。
This is my first question, and I would appreciate you answering soon.
我想代码连续重复一个功能...
我有尝试了一些代码,但它没有用。
I would like code to repeat a function continuously... I have tried some code but it hasn't worked.
我试过这段代码:
<script type="text/javascript">
$(function()
{
$('#more').load('exp1.php'); // SERIOUSLY!
});
</script>
我希望在一段时间后重复此功能。我试过
setInterval()
和 setTimeout()
I want to repeat this function after some interval. I have tried
setInterval()
and setTimeout()
但是,我还没有收到结果。
But, I haven't received results.
推荐答案
这将重复任务直到你清除间隔( with clearTimeout(repater))
This will repeat the task until you clear the interval (with clearTimeout(repater))
var repeater;
function doWork() {
$('#more').load('exp1.php');
repeater = setTimeout(doWork, 1000);
}
doWork();
每个OP的原始条件:
我希望代码能够连续重复...
I want code that repeat function continuously...
这篇关于以时间间隔连续重复运行JavaScript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文