Home>

Is it possible to wait for the completion of processing during the following loop and proceed to the next step?

$. each (array, function (i, val) {
1. Perform time-consuming processes such as AJAX
2. When processing is complete, proceed to the next loop
});
If i set

setTimeout, the following loop process may be executed before the process ends.

$. each (array, function (i, val) {
    setTimeout (function () {
        Execute processing
    }, 1000 * key);
});