Ah, it's still an old topic. It's always around Chinese people ......
Let's go
The project uses version 1.2.6 in the early stage and Version 1.3.2 in the later stage;
Let's talk about the implementation method. It's a bit violent-directly modify the jqury source code, but don't worry, it won't affect the overall function, and you can fix the garbled code by modifying a few lines of code, that is, when sending a request, transcode the parameter value again. The modification method isParam
1. jquery1.2.6Garbled Solution
- Open the source file version 1.2.6
- Locate the rows 2,911st, 2921, and 2924, and modify the corresponding parameter values to enclose the encodeuricomponent. The modified result is as follows:Param: function (a) {<br/> var S = []; </P> <p> // If an array was passed in, assume that it is an array <br/> // of form elements <br/> If (. constructor = array |. jquery) <br/> // serialize the form elements <br/> jquery. each (A, function () {<br/> S. push (encodeuricomponent (this. name) + "=" + encodeuricomponent (this. value); <br/>}); </P> <p> // otherwise, assume that It's an object of key/value pairs <br/> else <br/> // serialize the key/values <br/> for (VAR j In) <br/> // if the value is an array then the key names need to be repeated <br/> if (a [J] & A [J]. constructor = array) <br/> jquery. each (A [J], function () {<br/> S. push (encodeuricomponent (j) + "=" + encodeuricomponent (this); <br/>}); <br/> else <br/> S. push (encodeuric Omponent (j) + "=" + encodeuricomponent (jquery. isfunction (A [J])? A [J] (): A [J]); </P> <p> // return the resulting serialization <br/> return S. join ("&"). replace (/% 20/g, "+"); <br/>}< br/>
Download: jquery-encode-gbk.1.2.6.js
Download: jquery-encode-gbk.pack.1.2.6.js
2. jquery1.3.2Garbled Solution
1.3.2 does not need to be so troublesome, because this version simplifies the structure of the param method and only needs to modify a line of code, because transcoding is only available in one place.
Locate row 3,737th and enclose an encodeuricomponent. The result is as follows:
Param: function (a) {<br/> var S = []; </P> <p> function add (Key, value) {<br/> S [S. length] = encodeuricomponent (key) + '=' + encodeuricomponent (value); <br/>}; <br/>
Download: jquery-encode-gbk-1.3.2.js
Download: jquery-encode-GBK-. pack.1.3.2.js
Reprint please indicate the source http://blog.csdn.net/shimiso
Technical Exchange Group: 173711587