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

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是否有任何异步请求处理,这样我就不允许提交表单了吗?

推荐答案

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

Jquery相关问答推荐

在shiny 的datatable列中启用智能搜索

jQuery .first() 方法返回第一个元素的集合

formData.append 来自不同输入文件的两个文件

哪个 JQuery Select 器会排除与给定 Select 器匹配的父项的项目?

jQuery函数从数组中获取所有唯一元素?

如何使用 jQuery 获取所有 ID?

如何使用 jQuery 禁用粘贴(Ctrl+V)?

jQuery 与 javascript?

jQuery.parseJSON 单引号与双引号

如何从 jQuery 中的父级中 Select 所有子级(任何级别)?

页面滚动后,jQuery可拖动在错误的位置显示助手

jquery-ui datepicker更改z-index

jQuery .load() 调用不会在加载的 HTML 文件中执行 JavaScript

从父 node 中删除所有子 node ?

虽然未定义变量 - 等待

bootstrap 模式:关闭当前,打开新

通过 :not 在 jQuery Select 器中隐藏除 $(this) 之外的所有内容

Chrome 中的 AJAX 发送选项而不是 GET/POST/PUT/DELETE?

是否可以将 async:false 设置为 $.getJSON 调用

jQuery中的wait()或sleep()函数?