Based on the last experience, I will copy the code
as follows: contentType: "application /x-www-form-urlencoded; charset=utf-8", was added to the parameters of the ajax request, but it didn’t work this time.
After observing the Fiddler results many times and finding that it was invalid, I had to open JQuery.Validation.js to find the answer.
In the remote code, I found:
var data = {};
data[element.name] = value;
$.ajax($.extend(true, {
url: param,
mode: "abort",
port: "validate" element.name,
dataType: "json",
data: data,
....
It turns out that the plug-in defines the submitted data and directly transmits the data to be verified to the server in json format. No wonder the encoding definition for the form is invalid, and the value is forced to encodeURIComponent(value), and it works!
Postscript:
This method must explicitly decode the data when processed by the server code, and its versatility is very poor. Therefore, I will go back to the starting point to study a better method. >
In order to prevent the Validation plug-in from processing the input data, I tried to use my own Option to override Validation’s Option definition:
Copy code
type: "post",
dataType : "json",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
data: { txt1: function() { return $("#txt1").val (); } }
}
Then in the server-side code, obtain the corresponding data in the Form data, thus avoiding the modification of Validation and meeting my requirements.
Original link:
http://www.luyuliang.com/post/chinese-issue-in-jquery-validation-plugin.aspx