Jquery submit form broken

后端 未结 6 1065
伪装坚强ぢ
伪装坚强ぢ 2021-01-26 04:45

I tried stop form refreshing the page but it refreshes page every time i submit the form.



        
6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-26 05:05

    A submitted form will always refresh/redirect the page, to avoid it all you have to do is:

    ​​​​​​​​​​​​​

    returning false on the submit handler will prevent the form from submitting, and the page from refreshing, and there really is no need for jQuery just to prevent a form!

    To both send the form to the server and not have the page refresh will however require the use of Ajax, and jQuery has some great ajax functionality built in, but it looks like you need to read up a little on the jQuery website.

提交回复
热议问题