I have my project with ASP.NET Core. In a page The web application reads data from a Web API. Usually, the data are quite big: data.Rows
could have 15000 rows. I want to add each row to a table but at the same time I want to give to the user the progress status.
$.ajax({
url: url,
data: 'filename=' + filename,
dataType: 'json'
})
.fail(function (err) {
alert(err);
})
.done(function (data) {
var dataLength = data.Rows.length;
$.each(data.Rows, function (index, obj) {
console.log('Reading ' + index + ' rows of ' + dataLength)
if ($('#progressbar').length)
$('#spanMessage').html('Reading ' + index + ' rows of ' + dataLength);
tbl += '<tr>';
var num = 0;
$.each(obj, function (_, text) {
tbl += '<td>' + text + '</td>';
num++;
});
if (num < data.Headers.length)
for (var i = 0; i < data.Headers.length - num; i++) {
tbl += '<td></td>';
}
tbl += "<td></td></tr>";
});
tbl += '</tbody>';
}
This is a long process and the UI doesn't change. After the process is completed, I can see the table as expected.
How can I update the UI regurarly?