How to wait for ajax validation to complete before submitting a form?

前端 未结 7 864
悲哀的现实
悲哀的现实 2020-12-20 23:00

Having a problem where the form submits before the validateUsername function has a chance to complete the username check on the server-side.

How do I submit the form

相关标签:
7条回答
  • 2020-12-20 23:27

    More verbose version of Olafur's answer - The AJAX call is made and the function returns without waiting.

    The callback doesn't finish until you've submitted the form.

    What you should do is have the button/trigger calling the AJAX validation, and the callback should submit the form instead of returning true.

    0 讨论(0)
提交回复
热议问题