Serialization of Chinese is garbled because. Serialize () called the Encodeurlcomponent method to encode the data
The workaround is to decode
Cause:. Serialize () automatically calls the encodeURIComponent method to encode the data
Workaround: Call decodeURIComponent (xxx,true); decode the data
Product label
function tag (URL) {
var form = $ (' form '). Serialize (); Serialization of content
var Shuju = decodeuricomponent (form,true); Decode the data
alert (Shuju);
return false;
if (Url.indexof ("?") >= 0) {
var newurl = URL + $ (' form '). Serialize ();
Window.location.href = Newurl;
}else{
var form = $ (' form '). Serialize ();
var Shuju = decodeuricomponent (form,true);
alert (Shuju);
var newurl = url + '? ' + Shuju;
Window.location.href = Newurl;
}
}
//解决办法:将解码方式unscape换为decodeURI
//原因:浏览器会将url中的中文参数进行encodeURI编码,所以要通过js使用decodeURI进行解码
var url = decodeuri (location.href); The decodeURI () function decodes a URI encoded by the encodeURI () function.
JQ gets the content of Baidu editor
var test = editor.getcontent ();
The solution to the problem of Chinese garbled characters in jquery using Serialize () Form serialization