Home > Web Front-end > JS Tutorial > body text

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

coldplay.xixi
Release: 2023-01-04 09:36:58
Original
2011 people have browsed it

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!