Ajax Form submit with preventDefault

后端 未结 4 834
予麋鹿
予麋鹿 2020-11-30 13:55

I have a normal HTML form in which it is supposed to prevent default form submit and post the values by Ajax. It is not working with my setup Please help me where I went wr

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 14:35

    set the submit button as type="button" instead of type="submit",

    and let's say the submit button has id submit-button. you can submit the form in javascript like this:

    $("#submit-button").click(function(){ 
     //send ajax
    })
    

提交回复
热议问题