我如何知道 jQuery 是否有待处理的 Ajax 请求?
我在使用我们制作的 jQuery 控件时遇到了一些问题.假设您有一个下拉列表,允许您输入要查找的项目的 ID,当您按 ENTER 或在文本框中失去焦点时,它会通过 jQuery 验证您输入的 ID 是否正确,如果没有则显示警报不.
I'm having some problems with a jQuery control we made. Suppose you have a dropdownlist that allows you to enter the ID of the item you're looking for, and when you press ENTER or lose focus in a textbox it validates via jQuery that the ID you entered is correct, showing an alert if it doesn't.
问题是当普通用户在其中输入了一个无效的值并通过按下提交按钮失去焦点时,jQuery post在表单的提交发送后返回.
The thing is that when an ordinary user enters an invalid value in it and loses focus by pressing the submit button, the jQuery post returns after the submit of the form has been sent.
有什么方法可以检查 jQuery 是否有任何异步请求处理,以便我不允许表单提交?
Is there any way that I can check if there's any Async request processing by jQuery so that I do not allow the form submit?
推荐答案
你可以使用 ajaxStart和 ajaxStop 来跟踪请求何时处于活动状态.
You could use ajaxStart and ajaxStop to keep track of when requests are active.
相关文章