I’m having a little trouble figuring out how to do an action when submiting a form, but before it is sent. The thing is that the action tag redirects the user to a different site, and I need AJAX to send an email when I click the submit button. The user should be redirected even if AJAX fails.
I read about $.ajax() but I don’t understand how to stop the form submition until jQuery gets a response. Is it done automatically?
On another thread I saw that it’s recommended to use an input type “button” instead of submit.
I know that this would allow me to manuallydo a $(form).submit(); later, giving me better control, but I still strugle to fully understand the previous part.
I know the answer to this is very simple, and I’m probably running in circles over complicating myself!
Thanks for your help!
To prevent form submission until the ajax request completes, you can disable the
asyncoption.