Is there a way to check if there's ajax request in progress? Something like:
if ( $.ajax.inProgress ){ do this; } else { do that; }
Is there a way to check if there's ajax request in progress? Something like:
if ( $.ajax.inProgress ){ do this; } else { do that; }
You should basically set a variable on top of script set to
false
and on ajax initiate set it totrue
and in thesuccess
handler set it tofalse
again as described here.If you are in full control of the javascript code you could increment a variable whenever you start an ajax request and decrement it when the request completes (with success, failure or timeout). This way you always know if there is a request in progress.
You might like this:
To abort ajax request, Use
To continue running ajax request, Use
yes there is
the beforeSend will do the process you need to do when the ajax request has just started and complete will be called when the ajax request is complete.
documentation