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
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
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)
function foo(){
console.log('function is being called')
}
setInterval(function(){
foo()}, 30000)
The second argument in setInterval is the time delay in milliseconds, so use 30000 for 30 seconds, not 30.
function blah(){}
blah();
setInterval(blah,30000);