In one HTML page I have a JavaScript function checkUpdates() that hits the server. I make this function run every 5 seconds with this line:
window.setInterval("checkUpdates()", 5 * 1000);
In Firebug, I put a breakpoint inside the checkUpdates() function. However, after the code execution stops at this breakpoint, pressing “continue” sometimes doesn’t do anything. All the JavaScript on my page appears to have stopped.
Does this have something to do with the above line of code? Does the loop that executes checkUpdates() every 5 seconds pause when I am at a breakpoint, or does it continue running in the background? I wonder if waiting longer than the 5-second interval to press “continue” is what causes things to break.
Side note: I am new to Javascript and event-driven programming in general, so I am still a bit fuzzy on a few of the paradigms, such as whether code gets executed sequentially or concurrently. Any pointers to reading material on this would be appreciated.
Does the loop that executes checkUpdates() every 5 seconds pause when I am at a breakpoint, or does it continue running in the background?
Yes, it does STOP everything!
but soon you click “Continue” or “Play” it will resume and continue to break in the same spot (I’m guessing that you are breaking inside the checkUpdates method.
use the Firebug in order to track this, it is very easy to use.
I just made a simple HTML file so you can see this running
There’s also a screencast here.
code : http://jsbin.com/izazu <– remember that you can edit adding /edit in front of the url.