I have got code like this
var challegneListener;
$(document).ready(function(){
var challegneListener = setInterval("challengeListenerBot()",5000);
});
function challengeListenerBot(){
clearInterval(challegneListener);
}
And the problem is that the interval does not stop, becouse function called challengeListenerBot does not see challegneListener variable as number of interval. I must use jQuery to start interval when the document is ready.
Change this:
To this:
The problem is you’re declaring inside your anonymous function, called when the DOM is ready, a new
challengneListenervariable. It hides the global variable, and only saves the setInterval ID to the local variable, which is garbage collected when its enclosing function has finished executing.