I have a for block that iterates a list of objects. Each object's name will be displayed in a div (#console).
When the code runs, console.log is output-ed in real time. However, it seems that the method that is supposed to append data to #console executes only after when the for block completes.
How do I make doSomething() run in real time as well?
for(var i = 0; i < objectList.length; i++)
{
console.log(objectList[i]); // this runs immediately
doSomething(objectList[i]); // this runs only AFTER the loop completes
}
function doSomething(obj)
{
$("#console").append(obj.name);
// other stuff
}