My js-script calculates a lot of data. For instance, sql.js updates my sqlite database. I want to create a callback with probress bar and text. But the text in html web page is always not updated until the all of my calculations be done.
$array.each(function(index){
// CODE CODE CODE
$("#pbData").text(index + ' PROGRESS');
add_line_to_db(db,table_name,name,text);
// CODE CODE CODE
});
I tried to use something like
$array.each(function(index){
// CODE CODE CODE
setTimeout(function(){$("#pbData").text(index + ' PROGRESS');},1);
add_line_to_db(db,table_name,name,text);
// CODE CODE CODE
});
But it hasn't helped.
How to fix it?
EDIT
I'm createing a sqlite database using sql.js script. The script loops over a table and stores the data to my database. A user wants to see a progress bar of table looping. So, I want to create a callback function for each iteration of sql request.