How do i stop the form from reloading using Javascript?

后端 未结 5 1132
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 15:18

When a User Submits the form i want to stop the default behavior of the form. ie it should not reload. so that i can perform the AJAX request.

here is the code i use

5条回答
  •  春和景丽
    2020-12-01 15:55

    add a return in your event handler:

    onsubmit="return validateForm();"
    

    Otherwise the function executed, but doesn't tell the browser to halt processing.

提交回复
热议问题