jQuery ajax提交中文编码(gbk)解决
1. jQuery ajax提交请求(GBK)。中文, IE下正常,FireFox下乱码. 这个问题让人很蛋疼, 解决方式也比较纠结,
进行2次encodeURI, 然后后台再进行decode.
如下: tagNames 是中文.
var tagVal = encodeURI(document.getElementById("tagNames").value);
tagVal = encodeURI(tagVal);
var dataString = jQuery("#subscriptionForm").serialize();
dataString = dataString + "&tagNames=" + tagVal;
jQuery.ajax({
type: "POST",
url: "/subscription/",
data: dataString,
success: function() {
subscriptionSuccess();
}
});
JAVA 端后台decode.
tagName = URLDecoder.decode(tagName, "UTF-8");[@more@]