Recently, a fom plug-in of jquery was used. It is a jQuery plug-in that fully supports forms. When I submitted FormPost using ajaxSubmit yesterday, I found that the Chinese data retrieved by the server was garbled. This may be because jquery is UTF-8 and does not support many search methods on gb2312. It may be because of the jquery I used. form. js is Version 3.01, that is, the version (Khan... Is the day before yesterday), so it is generally not useful. I did not confirm whether the earlier version works, but most of them are not responsible for Copy. Some other methods are to encode all the values before submission. I think this is too troublesome. I have added a lot of front-end code, so I didn't take it.
Okay, you can handle it yourself. First, we need to find the entry point to solve the problem. Since we want to encode the data transmitted by JS, we must first start with the data transfer function. I am calling the ajaxSubmit function. Open the js file, find this function, check the source code, and find a line:
The Code is as follows:
Var qx, a = this. formToArray (options. semantic );
FormToArray is used to convert the collected form data into an array of objects and then pass it to Ajax functions such as $. get and $. post. I think there is a drama. But the next code is several hundred lines. To save time, let's go straight to the topic. I set a breakpoint on the line above, input Chinese data on the Web page, and debug the source code step by step through JS. After the program is executed, after several jumps, the last part of the fieldValue function is finally found:
The Code is as follows:
Return $ (el). val ();
In this way, we only need to encode the client here:
The Code is as follows:
Return escape ($ (el). val ());
Then on the Server side, you can use Server. UrlDecode () for decoding. In this way, garbled characters are not displayed and Chinese characters can be correctly accepted ~~~
You can also propose any good methods or suggestions.