i've a problem stopping a JS chrono job..My code is:
var timerID = setInterval(function() {
$.ajax({
url: urltocall,
data: parameters,
dataType: "json",
success: function (data) {
if (data=='go' && checkShow =='0') {
DO SOME ACTIONS
}
},
error: function(){
console.log('Error on timeSession.js ajax call');
}
});
}, interval * 1000);
This code is included in my header.php so it's executed very time the site is open :)
Add: as i wrote this JS file is included in my header.php so it's included in every page in my site. When the function get the GO value from the ajax call the site is redirected to another page (thanks a location.href = XXXX;) but because of the header.php the setinterval restart after the new page is loaded.
how can i block after changing page?