The submitHandler commit of the jQuery validate plug-in leads to an endless loop solution. jqueryvalidate is submitted.
This article describes the solution to the endless loop caused by submitHandler submission of the jQuery validate plug-in. We will share this with you for your reference. The details are as follows:
The dom submits form. submit (); and jquery submits $ (''). submit ();. There is no difference in the function. However, if the jquery validate plug-in is used, the two are significantly different during submission. $ (''). When submit () is submitted, jquery validate is verified. If $ ('') is written in submitHandler (''). submit (); will lead to an endless loop, while form. submit (); then no.
This problem is a small problem. If you do not pay attention to it or get used to it, it is easy to make mistakes. In case of errors, it is difficult to find out. It took me nearly two hours to find the reason.
I. Briefly describe dom and jquery
Dom object. You need to write JavaScript code to operate the object, tag in the page. For jquery, you must use the jquery syntax.
It is also very easy to convert a dom object to a jquery object. Just add $ (), and then you can use the jquery syntax to operate the object. I think this is the most common use. Let's take a look at the example.
$ ('Input [name ^ = "hour"] '). each (function (index) {this. value = index; // this is a dom object, js format}); $ ('input [name ^ = "hour"] '). each (function (index) {$ (this ). val (index); // $ (this) is a jquery object, written in jquery });
Ii. jquery validate endless loop Program
$("#product_form").validate({ focusInvalid:false, submitHandler: function(form){ $('.submit').submit(); }});
Correct writing,
$("#product_form").validate({ focusInvalid:false, submitHandler: function(form){ form.submit(); }});
When an endless loop occurs, the browser will remain in the loading State until the Browser fails. At this time, you can add an alert and you will know that validate is continuously in the loop verification process. I personally think that although it is a small problem, it is hard to remember.