Home >Web Front-end >JS Tutorial >What should I do if Chinese garbled characters appear when jquery uses serialize()?

What should I do if Chinese garbled characters appear when jquery uses serialize()?

coldplay.xixi
coldplay.xixiOriginal
2020-12-11 13:40:382097browse

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. .

What should I do if Chinese garbled characters appear when jquery uses serialize()?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn