> $.ajax({ > type: "GET", > url: "/path/to/jsonfile.js", > datatype: "json", > success: > // lots of code to parse and display > $.each(json.object, function(key,array){ > // lots of code to parse and display > incr++; > if( incr % 10 === 0 ) { > $('#loaderCounter').text(' (loaded '+incr+' rows)'); > } > }); > hideLoading(); > });
The problem with that is that changing DOM content while in a tight loop isn't necessarily going to be honored by the browser (until the current thread returns). If you want a reliable x-browser solution you need to introduce an asynchronous step so that the browser takes time to render the change.