1
I have a setInterval
with an interval of 2 seconds.
I need to stop this interval at a certain point and start it again with a new time.
Scope
I do an AJAX inside the setInterval. Just when the AJAX response is Success (for example), it repeats the interval again. If it is error, it stops the interval, changes the interval time, and restarts it again.
I managed to do the following until the moment:
var TempoRequest = 2200;
var Ativo = true;
if(Ativo === true){
VerificaChat = setInterval( function(){
if(acao){
//repete o intervalo dnv
}else{
var Ativo = false;
var TempoRequest = 15000;
clearInterval(VerificaChat);
}
}, TempoRequest );
}
First I need to know at what point do you want it to stop and at what point a new time is added? It gets very vague that way you asked, can I stop with click or pass mouse, how do you want to stop setinterval and how do you want to restart it with new time? What are you thinking?
– Felicio Neto
It’s like I do an AJAX inside that setInterval. Just when the AJAX date response is Success (for example), it repeats the interval again. If it is error, it stops the interval, changes the interval time, and restarts it again. Got it?
– Vitor Leite