Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a function every 30 seconds javascript

I am trying to run a function every 30 seconds but setInterval waits 30 seconds then runs it repeatedly. So if there are any other methods of going about this. (Without 3rd party plugins)

Any help would be appreciated

like image 913
user2580555 Avatar asked Feb 07 '14 21:02

user2580555


1 Answers

Based on the answer from "Schechter" but fixed to run on the first page load and then runs every 30 secs.

function myFunction(){
    console.log('myFunction Called')
}

myFunction();

setInterval(function(){
    myFunction()
}, 30000)
like image 130
Gary Carlyle Cook Avatar answered Oct 16 '22 06:10

Gary Carlyle Cook