This article mainly introduces the quick solution to the problem that the Ajax form page will still be refreshed when submitting the Form form, and the automatic refresh after the Ajax submission when there is a button in the form form. Question, friends in need can refer to it, I hope it can help everyone.
After working on it for a long time, it turned out that the type="button" was added when clicking the submit button. It turned out to be
The result will be refreshed no matter what. Page, just add itPS: When there is a button in the form, the problem of automatic refresh after ajax submission
//在记一个坑(刚学前台,不是很懂,项目中自己给自己挖了个坑,哈哈...) <form class="form-horizontal"> <p class="form-group"> <label class="col-sm-3 control-label">修改资料名称:</label> <p class="col-sm-7"> <input type="text" placeholder="test22" class="form-control"></p> <p class="col-sm-2"> <button class="btn btn-primary" onclick="resetCertificateName(14)">修改</button> </p> </p> </form>
When there is a button label in the form, after submitting the form asynchronously with ajax, it will also The page will be refreshed. (It feels very weird)
Cause: When the button exists, the form will be submitted again, so the page is refreshed. (Previously, when button type='submit' was considered) button only has the function of submitting the form.
Solution: Just replace the button label with a label. Modify
Related recommendations:
Lavarel Framework Example sharing of using ajax to submit a form
Ajax submission form page refreshes very quickly Example explanation
The above is the detailed content of Ajax submission form form page will still refresh j solution. For more information, please follow other related articles on the PHP Chinese website!