Home > Article > Web Front-end > A quick solution to the problem that Ajax submits the Form form page and still refreshes
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 a4af873a37bdc4491a2626923f3f532f 3039fe2f1fcb2bdbba9f579be2c98ebb f5a47148e367a6035fd7a2faa965022e
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. d04413216ad3fb0b5df9799e5fc9fb89Modify5db79b134e9f6b82c0b36e0489ee08ed
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!