Jump to content

run a js script in BO


rayrayrugby

Recommended Posts

Why don't you just run the javascript every 10 seconds, instead of let php initiate it??

 

window.setInterval(function(){
/// call your function here
}, 10000);

 

(use clearInterval() to stop it)

 

 

Or, if you want to run it some fixed amount of times:

 

Make a function:

 

function setIntervalX(callback, delay, repetitions) {
  var x = 0;
  var intervalID = window.setInterval(function () {

    callback();

    if (++x === repetitions) {
      window.clearInterval(intervalID);
    }
  }, delay);
}

 

 

and then call using:

 

// This will repeat your logic every 10 seconds for 5 times:
setIntervalX(function () {
  // Your logic goes here
}, 10000, 5);

 

 

Hope this helps,

pascal.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...