jQuery Validation plugin: submitHandler not preventing default on submit when making ajax call to servlet - return false not working

前端 未结 5 1299
渐次进展
渐次进展 2021-01-14 06:35

I have a simple form that uses jquery and a servlet. The jquery makes an ajax call to the servlet, the servlet makes some server side calculations, then displays the result

5条回答
  •  梦谈多话
    2021-01-14 07:25

    By the time the submit event has fired it's too late to prevent the form from submitting. You should bind to the click event on the submit button and use event.preventDefault() to stop it from submitting. If your validation routine completes successfully you can use $.serialize() and $.submit() to manually submit the form.

提交回复
热议问题