Home >Web Front-end >JS Tutorial >What should I do if Chinese garbled characters appear when jquery uses serialize()?
The reason [.serialize()] automatically calls the encodeURIComponent method to encode the data. The solution to the Chinese garbled code when jquery uses [serialize()]: call [decodeURIComponent(XXX,true);] to decode the data. .
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, thinkpad t480 computer.
Recommendation: jquery video tutorial
Solution to Chinese garbled characters when jquery uses serialize():
Cause:.serialize()
The encodeURIComponent method is automatically called to encode the data
Solution: Call decodeURIComponent(XXX,true);
Decode the data
For example:
var params = jQuery("#formId").serialize(); // http request parameters. params = decodeURIComponent(params,true);
Related learning recommendations: js video tutorial
The above is the detailed content of What should I do if Chinese garbled characters appear when jquery uses serialize()?. For more information, please follow other related articles on the PHP Chinese website!