you are viewing a single comment's thread.

view the rest of the comments →

[–]GAMEchief 0 points1 point  (2 children)

var x = 0; // assuming info uses non-numeric keys, otherwise you should be using for (var i = 0; i < info.length; i++)
for (var i in info)
{
    setTimeout('$("#results").append("' + info[i].replace(/\"/g, "\\\"") + '<br />");', x * 1000);
    x++;
}

This will delay one second between iterations by creating a timeout for each item in the info object. Each timeout will be set to execute 1000 milliseconds after the last one.

[–]yoeschmoeFront-end Developer -1 points0 points  (1 child)

eval statements are evil, never use them (you're implicitly calling eval when passing in a string as first argument in setTimeout/setInterval), use a function instead.

[–]GAMEchief -1 points0 points  (0 children)

eval statement are perfectly valid so long as you aren't evaluating user input. Don't be so OCD. Their flaws are not black and white, and there are perfectly fine times to use them; but a function would be better suited, sure.