So i have a web app with basic authentication.
When im logged in, an Interval is set:
$(#login).click(function(e) {
var interval = setInterval(function(){myFunction();}, 2000); });
Then when im logged out i need to stop the interval:
$(#logout).click(function(e) {
if(typeof interval !== 'undefined') clearInterval(interval); });
But it doesnt work, i think the way to check if an interval exist is wrong...i can set the interval so it is running when im logged in, but i need to stop/clear it when i click on my Logout button and it doesnt...
PS. im using the interval to check myFunction automatically every 2 seconds, but maybe there is another way to accomplish this without an interval? thx