I am working on a div (parent) that has two more divs (menu and content) as shown below:
<div id="parent"> <div id="menu"></div> <div id="content"></div> </div>
Content uploaded to the content div is an html file with several javascript functions, such as automatic updating, which reloads its contents every 5 seconds.
$(document).ready(function () { setInterval(function () { grid.reloadDefaultContent();
There are several links on the page that load different contents into the contents of the div. So far so good, until I return to the "house", which has the auto-update function. The problem is that automatic updating never stopped, and now that I clicked to return home, the function runs twice (or how many times I change the page and return home), setting up a session. I am loading pages using jQuery $.load() .
Any ideas on how I can get this setInterval instance to run only once?
Edit: After reading my own question, I saw that this is a bit unclear. My main problem is that when I get home, my first instance of setInterval is already running, and the second is starting, making an automatic update that has passed 5 seconds, and it will go faster and faster every time I change the page and return home . This is not the behavior I want. I need a STOP instance of setInterval when I change the contents in a div, and reload it when I get home.
source share