我怎么知道 jQuery 是否有一个 Ajax 请求待处理? [英] How do I know if jQuery has an Ajax request pending?

查看:29
本文介绍了我怎么知道 jQuery 是否有一个 Ajax 请求待处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用我们制作的 jQuery 控件时遇到了一些问题.假设您有一个下拉列表,允许您输入要查找的项目的 ID,当您按 ENTER 或在文本框中失去焦点时,它会通过 jQuery 验证您输入的 ID 是否正确,如果不正确则显示警报't.

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?

推荐答案

你可以使用 ajaxStartajaxStop 以跟踪请求何时处于活动状态.

You could use ajaxStart and ajaxStop to keep track of when requests are active.

这篇关于我怎么知道 jQuery 是否有一个 Ajax 请求待处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆