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