This article mainly introduces in detail the solution to the problem that jquery submit() cannot submit the form. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.
When I wrote the form submission today, I needed to add a confirmation prompt, so I didn’t use the submit button to submit. Instead, I used jq’s submit(), and then there was a problem
Click the submit button and a confirmation prompt will appear, but after confirmation, there will be no response
But if you change the button type to submit, you can submit again
So I went to jQuery API to find the reason, and I immediately understood when I saw the following text:
Additional Notes:
Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.
It probably means that the form and its sub-elements should not use the attributes of a form as the name or id, such as submit, length, and method, otherwise conflicts will occur. Name conflicts may cause this.
It turns out to bebecause the button id is set to submit
Related recommendations:
How jQuery uses ajaxSubmit() to submit a form instance Detailed explanation
Example introduction to the difference between submit() in JQuery and JS
Overview of the submit() method and onsubmit event application of form elements_Basics Knowledge
The above is the detailed content of How to solve the problem that jquery submit() cannot submit the form. For more information, please follow other related articles on the PHP Chinese website!