javascript - Update DIV element on the page while looping an object -
i have function loops through object many elements using for loop. while looping through each element connects server , sends data through ajax, waits response , goes next element in object. if object has many elements can take 2 or more minutes before looping has finished. visually show on page how many elements left before looping has finished.
the problem screen freezes while looping. there way update div element on page while looping through object ?
var a;//let's assume array ... ... for(var =0;i<n;i++) { (function(a,b){settimeout(f(a,b),0);})(i,a[i]); } ... ... function f(current, element) { //call server api here //send data div using value of current }
Comments
Post a Comment