[jQuery] AJAX Forms: Checking for an in-flight XHR

[jQuery] AJAX Forms: Checking for an in-flight XHR


I have a table of items with various controls on each row for
performing functions on the item on that row. One function is
toggling whether or not to publish the item in question.
I'm using the form plugin to do this over AJAX. I have a beforeSubmit
function that changes the icon to a throbber to show something is
happening, and I have a success function that replaces the throbber
with a tick or a cross, depending on the new published status of the
item affected. It all works okay, but I coudl forsee things going
funky if the user tries to fire off a new AJAX request while another
one is in flight. For this reason I need to disable the submitted
form for the duration of the AJAX request.
The documentation for the form plugin says that if the beforeSubmit
callback returns false then the submit is aborted. So I'm thinking I
can use the beforeSubmit callback to check for an in-flight AJAX. If
it finds one then return false, otherwise set the image of the form's
submit button to the throbber.
I just need to know, how can I do that?