1

I'm trying to run refreshPage() every minute in a google web app. Although I cannot seem to get the function to repeat. Does anyone see any issues? It runs correctly the first time.

  $(document).ready(function(){
      setInterval(refreshPage(), 60000);
  });

  function refreshPage()
  {
      google.script.run.withSuccessHandler(googlescript).myfunction();
  }

2 Answers 2

2

The only problem is you call your function in set interval and then setInterval gets undefined as function. this is the solution (just remove parentheses in front of refreshPage in setInterval):

$(document).ready(function(){
    setInterval(refreshPage, 60000);
});

function refreshPage()
{
    google.script.run.withSuccessHandler(googlescript).myfunction();
}

If you want it to run once at the beginning then you can change you can use one of these suggestions:

function refreshPage() {
  console.log('refresh page');
}
refreshPage();
setInterval(refreshPage, 1000);

or

(function refreshPage() {
  console.log('refresh page');
  setTimeout(refreshPage, 1000);
})();

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

Comments

1

possible solution

setInterval(function(){ google.script.run.withSuccessHandler(googlescript).myfunction(); }, 6000);

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.