cooper_semantics — 2011-12-03T23:55:50-05:00 — #1
I come to you in need of help. If anyone could help me out, I'd greatly appreciate it.
When I click "End", it doesn't destroy (lack of a better word) the setTimeout function.
You'll notice the json file is called, at some point 6 times
I left a console.log in the code to show you the issue I speak of (so ensure you have your console open).
By default the json file should load once, then upon clicking "Start", the json file needs to be called (every x secs) until "End" is clicked (in which case the polling will stop).
aussiejohn — 2011-12-04T00:37:44-05:00 — #2
I just had a quick look at your example page and everything seemed to work just fine. Are you still having an issue?
If you're talking about the number that's returned by console.log(_this.setPolling), that's the ID of the setTimeOut not the # of times it's been called.
cooper_semantics — 2011-12-04T00:49:40-05:00 — #3
Thanks for the quick response (that's good to know). If you click "Start" & "End" a few times, you'll see the number of requests (json) double, if not triple. Let me know if you can't replicate the issue. Keep clicking a few times and you'll see.
Thanks again for your expertise.
aussiejohn — 2011-12-04T00:57:43-05:00 — #4
Ah, I see. It looks as if it's starting the polling setTimeOut multiple times.
I think the most straightforward way to get around that is to check if _this.setPolling is defined.
In addition to this, you will want to delete the reference to the timeout once it's been cleared, i.e.
cooper_semantics — 2011-12-04T01:21:13-05:00 — #5
aussiejohn — 2011-12-04T01:37:01-05:00 — #6
No worries dude, glad to be able to help