Reputation: 419
I am trying to change the speed of the interval for calling a function.
The first time it should take a second, and the rest should take nine seconds to call.
var tiempoCaratula=1000;
var refreshCaratula = setInterval(function() {
$('.col-2').load('caratula.php');
}, tiempoCaratula);
Upvotes: 1
Views: 300
Reputation: 11450
You could make a timeout that runs once at one second and a sub interval that runs every nine seconds after the timeout.
var tiempoCaratula = 1000;
var tiempoCaratula2 = 9000;
var refreshCaratula = setTimeout(function() {
$('.col-2').load('caratula.php');
var refreshCaratula2 = setInterval(function() {
$('.col-2').load('caratula.php');
}, tiempoCaratula2);
}, tiempoCaratula);
Upvotes: 1
Reputation: 7803
Run the first one using setTimeout
and then schedule it for future runs in whatever interval you need to.
var myFunction = function() {
$('.col-2').load('caratula.php');
}
var refreshCaratula;
// call the function after 1000ms
setTimeout(function () {
myFunction();
// then schedule it to run every 9000ms
refreshCaratula = setInterval(myFunction, 9000);
}, 1000);
Upvotes: 4