Skip to main content

How can I repeatedly call a JavaScript function?

Handy if you want to ensure your function has completed.

If you want to make sure you function has finished before you call it again, you can use setTimeout

(function repeat(){
  // Do stuff here
  setTimeout(repeat, 5000);
})()

If you don't care about the function finishing before you call it again, you can use setInterval.

setInterval(function(){
  // Do stuff here
}, 5000);

Hello, my name's Lee and I work as a full-stack web developer specialising in Microsoft ASP.NET technologies. I love using Umbraco and also MANAGED, my own interal CMS.

Contact me at lee.gunn@secretorange.co.uk

All skills

Contact

Get in touch to talk about your project or just ask me a question.

lee.gunn@secretorange.co.uk

Skype: lee_gunn