-1

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

Code:

window.setInterval('progress()', 10000);

Geetha.

2
  • 10000 milliseconds is 10 seconds... Does the function progress exist? Commented Mar 19, 2010 at 6:27
  • now i am using this code window.setInterval(progress(), 10000); function getting executed but not after the time interval. Commented Mar 19, 2010 at 6:32

2 Answers 2

1

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);

});
Sign up to request clarification or add additional context in comments.

1 Comment

This is wrong... it will call myfunction() as part of the setup of the interval, and use the return value. It should be providing a reference to myfunction instead: setInterval(myfunction,30000);
1

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.