开发者

javascript setInterval function not working

开发者 https://www.devze.com 2022-12-23 16:41 出处:网络
I want to call a function for every half minute. i am using the following code. The function is not getting triggered.

I want to call a function for every half minute. i am using the following code. The function is not getting triggered.

Code:

w开发者_如何学运维indow.setInterval('progress()', 10000);

Geetha.


Every half min would be 30,000 miliseconds

Example ...

refreshId = setInterval(myfunction(), 30000);

In jQuery you'd do something like ...

$(document).ready(function(){

    var refreshId = setInterval(myfunction(), 30000);

});

Or if you want to put your function within your refresh code ...

$(document).ready(function(){

    var refreshId = setInterval(function() {
        $("#myid").load('/mypage.html?update='+ Math.random());
    }, 30000);

});


I think the setInterval method may somehow fail to find the definition of the progress function.

Have you tried invoking setInterval with the function object directly?

window.setInterval(progress, 10000);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号