page has a pop-up window, which will do some operations in batches.
use the for loop to loop out the list, submit it to the interface in turn, and render the returned values to the page.
condition:
- for loop
- ajax must be synchronized
- render the page in real time, similar to progress
for (var i = 0; i < sn.length; iPP) {
$.ajax({
type: "post",
url: "aaa.action",
data: {"details.sn": sn[i], ...details},
async: false,
success: function (res) {
if (res.normal === 1) {
reMsg += `<li>${res.details.sn}: <span style="color: green">${res.msg}</span></li>`
$(".showSn").html(reMsg)
} else if (res.normal === 0) {
reMsg += `<li>${res.details.sn}: <span style="color: red">${res.msg}</span></li>`
$(".showSn").html(reMsg)
}
}
})
}
now the dom is updated in real time, but the pop-up window does not render in real time. It will not be rendered until all the interfaces have been executed:
the following figure
how do you write it if you want to use the generater function?
or, how do you write without the generater function?