I’m trying to work with wordpress to stop an ajax request sent by Jquery and re-submit it with some additional data.
Here’s how its working:
-
User clicks a submit button.
-
WordPress submits the ajax request
-
I have a global
beforeSendfunction set up using.ajaxSetupin this way:$.ajaxSetup( {beforeSend: monitorRequests } ); -
When wordpress submits the request, its intercepted by my function, which calls another function that submits another ajax request, while
monitorRequests‘ returns false, which cancels the original ajax request. -
My own ajax request is sent, without any problems.
However here’s the issue. After doing this once, if the user clicks the submit button again, wordpress’s click handler is not called. I’m wondering why this is, whether this has anything to do with the ajax request being cancelled? Or anything else? What should I do to make it so that the click handler continues to be called?
Figured it out, WordPress disables the button during the ajax request, and it remains disabled since wordpress’s callback is never called.