Hello colleagues, I have had a very annoying problem and it is as follows: I have a whole page made in ajax and jquery and I have different menus; and for example when entering the first menu, inside the HTML code I have an image with a Javascript onLoad method that loads a function, which executes another function called load () in a 20 seconds interval:
pagina.php
...
<img src="../images/calendario-semanal.png" alt="" border="0" onload="refresh_automatico();" />
...
sript.js
function refresh_automatico(){
$(document).ready(function(){
clearInterval(refreshId);
var refreshId = setInterval( function(){
load();
}, 20000 );
});
}
Until there everything perfect, just entered pagina.php, the script runs automatically refreshing every 20 seconds, but when I go to another page I see that it is still running and when I return to pagina.php I notice that the calls are duplicated and They are no longer 20 seconds but run many times. How do I stop that execution by clicking on another page of my project?
Thank you very much guys, I would thank you in your soul for your help.
Blessings