Using settimeout within loop to eliminate slight page freeze.
I have an ajax function that gets html data every 10 seconds and then runs a function that loops through an array and performs functions that update the content on the web page. I am trying to implement a settimeout within the loop to delay the dom inserts a little to eliminate slight page freezing in IE. The problem I am having is that I cant seem to pass in the variables within the loop to the functions. Can someone please assist? Below is a code snippet:
-
//Loop Through Items
for ( aIdx = 0; aIdx < availableItemsLength; aIdx++ )
{
var thisItemName = availableItems[aIdx];
var data = _serverData.find( "#" + thisItemName + "Data" ).html();
var detailData = _serverData.find( "#" + thisItemName + "DetailData" ).html();
setTimeout(function(){
updateItemData( data, thisItemName );
updateItemDetailData( detailData, thisItemName );
}, 10);
}