Is there any way to update a HTML progress bar (or any component) in Ajax request by server side?
For example (simulated):
JavaScript:
$.ajax({
url: '/Sales/SaveStoreByType',
type: 'POST',
data: {
locationId: id
},
success: function (result) {
...
},
error: function (xhr, ajaxOptions, thrownError) {
...
},
update: function(percent){
MyProgressBar('update',percent);
}
});
and server side:
public IActionResult SaveStoreByType(short locationId)
{
foreach (var item in collection)
{
//here simule a heavy process and update progress bar
i++;
ajaxrequest.update(i);
}
return Json(new { error = 0 });
}
Thanks