問題描述
我在使用我們制作的 jQuery 控件時遇到了一些問題.假設(shè)您有一個下拉列表,允許您輸入要查找的項目的 ID,當(dāng)您按 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.
問題是當(dāng)普通用戶在其中輸入了一個無效的值并通過按下提交按鈕失去焦點時,jQuery post在表單的提交發(fā)送后返回.
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 來跟蹤請求何時處于活動狀態(tài).
You could use ajaxStart and ajaxStop to keep track of when requests are active.
這篇關(guān)于我如何知道 jQuery 是否有待處理的 Ajax 請求?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!