This article mainly introduces the quick solution to the problem that the Ajax form page will still refresh when submitting the Form form, and when there is a button in the form form, it will automatically refresh after the Ajax submission. Question, friends who need it can refer to
After a long time, I clicked the submit button and added a type="button"
It turned out to be <form > <button id ="sub" /> </form>
No matter how you do it, the page will be refreshed, just add it
PS: When there is a button in the form, after the ajax submission Automatic refresh problem
<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 tag in the form, the page will be refreshed after asynchronously submitting the form using ajax. (It feels very weird)
Cause: When the button exists, the form will be submitted again, so the page is refreshed. (Previously thought button type='submit'
) button has the function of submitting the form.
Solution: Just replace the button label with a label. <a class="btn btn-primary" onclick="resetCertificateName(14)">Modify</a>
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future. help.
Related articles:
AJAX display loading and pop-up layer occlusion page implementation example
How to use ajax to submit forms in the Lavarel framework_AJAX related
The above is the detailed content of A quick solution to the problem that Ajax submits the Form form page and still refreshes. For more information, please follow other related articles on the PHP Chinese website!