Javascript Recursion
Posted
by
rpophessagr
on Stack Overflow
See other posts from Stack Overflow
or by rpophessagr
Published on 2011-01-15T08:41:24Z
Indexed on
2011/01/15
8:53 UTC
Read the original article
Hit count: 214
I have an ajax call and would like to recall it once I finish parsing and animating the result into the page. And that's where I'm getting stuck.
I was able to recall the function, but it seems to not take into account the delays in the animation. i.e. The console keeps outputting the values at a wild pace.
I thought setInterval might help with the interval being the sum of the length of my delays, but I can't get that to work...
function loadEm(){
var result=new Array();
$.getJSON("jsonCall.php",function(results){
$.each(results, function(i, res){
rand = (Math.floor(Math.random()*11)*1000)+2000;
fullRand += rand;
console.log(fullRand);
$("tr:first").delay(rand).queue(function(next) {
doStuff(res);
next();
});
});
var int=self.setInterval("loadEm()",fullRand);
});
}
});
© Stack Overflow or respective owner