How to deal with Chinese garbled characters when using serialize() in jquery

The reason [.serialize()] automatically called the encodeURIComponent method to encode the data. The solution for Chinese garbled characters using serialize() in jquery: call [decodeURIComponent(XXX, true);] to decode the data.



The operating environment of this tutorial: windows7 system, jquery 3.2.1 version, this method is applicable to all brand computers.

Recommendation: jquery video tutorial

jquery uses serialize() to appear Chinese garbled solutions:

Reason: .serialize() automatically calls the encodeURIComponent method to encode the data.

Solution: calls decodeURIComponent(XXX,true); decodes the data

For example:

1

2

var params = jQuery("#formId").serialize(); // http request parameters.

params = decodeURIComponent(params,true);

Related learning recommendation: js video tutorial

Guess you like

Origin blog.csdn.net/mjian178/article/details/113091682