Как я знаю, имеет ли jQuery ожидание запроса Ajax?

Существует страница на Wiki Wireshark, которая решает проблему. Короткий ответ, Вы не можете сделать этого на машине Windows, но могли бы быть некоторые обходные решения.

85
задан skaffman 30 November 2009 в 22:57
поделиться

2 ответа

Вы можете использовать ajaxStart и ajaxStop , чтобы отслеживать, когда запросы активны.

36
ответ дан 24 November 2019 в 08:08
поделиться

The $.ajax() function returns a XMLHttpRequest object. Store that in a variable that's accessible from the Submit button's "OnClick" event. When a submit click is processed check to see if the XMLHttpRequest variable is:

1) null, meaning that no request has been sent yet

2) that the readyState value is 4 (Loaded). This means that the request has been sent and returned successfully.

In either of those cases, return true and allow the submit to continue. Otherwise return false to block the submit and give the user some indication of why their submit didn't work. :)

11
ответ дан 24 November 2019 в 08:08
поделиться
Другие вопросы по тегам:

Похожие вопросы: