I got this javascript recursive function:
function doStuff(graphName) {
var groupArray = new Array();
groupArray[0] = "hour";
groupArray[1] = "day";
groupArray[2] = "month";
for(var i = 0; i < groupArray.length; i++) {
$.get("getchartdata", {"graphName" : graphName, "subgroup" : groupArray[i]})
.done(function(jsonData){
var data = eval(jsonData);
drawChart(data, data[0][0], data[0][1]);
});
}
setTimeout(doStuff, 10000);
}
Now the problem is that it works great the first time, but after 10 seconds when tries again, it shows an error:
TypeError: data[0] is undefined in drawChart(data, data[0][0], data[0][1]);
Why could this be happening?
If I add the parameter in setTimeout(doStuff(graphName), 10000);
The browser crashes.
Thanks.
evalthere! (Not for JSON parsing, and not when it is already parsed)async: false!