V
V
Vitaly Pitalenko2021-10-04 14:52:40
AJAX
Vitaly Pitalenko, 2021-10-04 14:52:40

Is it possible to track the completion of all synchronous post requests?

There is a cycle in which ajax are called with post requests synchronously (async:false). Is it possible to track and execute an action after all requests are completed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2021-10-04
@Rikisan

If requests are called synchronously, then the loop will end only after all requests are completed, nothing else needs to be tracked.
But, it seems, in all modern browsers, synchronous requests are prohibited and Promise.all must be used.

W
WebEagle, 2021-10-04
@WebEagle

well, of course not the best example (side effect is present)

var flagStatus = new Map();
flagStatus('request1', 'init');
flagStatus('request2', 'init');
// ....
flagStatus('requestN', 'init');

// тут делаем вызовы в цикле, после каждого вызова меняем статус в flagStatus на finish (любой, чтобы вам было понятно что этот завершен)

// перед вызовом действия проверяем чтобы все в flagStatus было finish

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question