What to do if jquery serialization submits Chinese garbled characters

藏色散人
Release: 2023-02-09 10:40:28
Original
1501 people have browsed it

Solution to jquery serialization submission of Chinese garbled characters: 1. Open the corresponding jquery file; 2. Decode the data by calling the "decodeURIComponent(XXX,true);" method to solve the garbled code problem.

What to do if jquery serialization submits Chinese garbled characters

The operating environment of this tutorial: Windows 10 system, jquery version 3.2.1, DELL G3 computer

How to submit Chinese garbled characters through jquery serialization manage?

When using serialize() in jquery to serialize the form, the problem of Chinese garbled characters

//登录 $(".register-btn").click(function() { var form = $("#register-form").serialize(); //序列化中文时之所以乱码是因为.serialize()调用了encodeURLComponent方法将数据编码了 //原因:.serialize()自动调用了encodeURIComponent方法将数据编码了 //解决方法:调用decodeURIComponent(XXX,true);将数据解码 form = decodeURIComponent(form,true); //关键点 var formArray = form.split("&"); var obj = {}; for(var i = 0;i
        
Copy after login

Recommended study: "jQuery Video Tutorial"

The above is the detailed content of What to do if jquery serialization submits Chinese garbled characters. 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 Recommendations
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!