I want to include an AJAX call within a .submit()
handler so that I can proc开发者_StackOverflow中文版ess form data and send email confirmations before the form is fully submitted. Therefore I'd like to make the submission wait until the AJAX call is complete, so that I can cancel the submission or do other things based on the response.
How would I go about doing this?
There is no waiting in JavaScript.
The closest you can come is to stop the default action in the submit event of the form, and then call the submit method of the form element in the callback from the Ajax request.
精彩评论