How do I know if jQuery has an Ajax request pending?
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.
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.
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?
Solution 1:
$.active
returns the number of active Ajax requests.
More info here
Solution 2:
You could use ajaxStart and ajaxStop to keep track of when requests are active.