Quick solution to the problem of Ajax submitting form page will refresh


After working for a long time, there was less click Submit buttontype="button"It turned out to be  <form >  <button />   </form> As a result, it will refresh the page, plus it

There is an automatic refresh problem of Ajax after submitting button in PS: form form form

//I was just learning from the front desk. I didn't know very well. I dug a hole for myself in the project. Ha ha
< label > name of modified data: < label >
<div> <input type="text" placeholder="test22"></div>
< button onclick = "resetcertificatename (14)" > Modify < / button >

When there is a button tag in the form, after the form is submitted asynchronously with Ajax, the face will also be refreshed. (feels weird)

Reason: the form will be submitted again when the button exists, so the page is refreshed. (previously thoughtbutton type='submit' Button has the ability to submit forms.

Solution: replace button tag with a tag。 < a onclick = "resetcertificatename (14)" > Modify</a>

The above is a quick solution to the problem that the Ajax form page submitted by Xiaobian will still refresh. I hope it will help you. If you have any questions, please leave a message to me and Xiaobian will reply to you in time. Thank you very much for your support of the developepaer website!

Recommended Today

Python basics Chinese series tutorial · translation completed

Original: Python basics Python tutorial Protocol: CC by-nc-sa 4.0 Welcome anyone to participate and improve: a person can go very fast, but a group of people can go further. Online reading Apache CN learning resources catalog introduce Seven reasons to learn Python Why Python is great Learn Python introduction Executing Python scripts variable character string […]