jquery.timers.js - updating variable and passing it each loop
Hi
I'm using jquery.timers.js and not really understanding variable scope in jquery. I've found lots of demos where the timer count is updated and passed to the next iteration of the timer but
a) I don't understand where it's being updated and
b) I can't seem to replicate that with another variable.
Here's what I have, a page with a div with id="live-player-1", trigger() is called on my page and then I attach the function in everytime to that div. I'm trying to create a generic function, checkForLive(uri, target, current, count), where I pass it a few variables. I can get the variables in for the first time of everytime but I need to update the current variable each time and use it. I know I'm close but I can't find any examples which explain how to do this to me even though it seems like it would be one of the first things you would want to do with a timer.
Any help much appreciated
Garrett
- <script type="text/javascript">
- <!--
- function trigger()
- {
- var current = 5;
- var count = 0;
- $("#live-player-1").everyTime(1000, function(count) {
- checkForLive('check.json', $(this), current, count);
- });
- }
- function checkForLive(uri, target, current, count)
- {
- alert(current);
- current = current + 1;
- }
- //-->
- </script>