开发者

How do I make form submission wait for an AJAX callback in jQuery?

开发者 https://www.devze.com 2023-01-12 17:37 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消