jQuery使用serialize()表单序列化时出现中文乱码问题的解决办法
function updateRemark() {
var data = {};
var str = $("#ver-form").serialize();
str = decodeURIComponent(str,true);
data.remark = str + "&eventId=" + eventId;
$.ajax({
type: "POST",
url: '${servletPath}/event/updateRemarkEvent.data',
data: data,
async: false,
dataType: "json",
success: function (data, textStatus) {
},
contentType: "application/x-www-form-urlencoded"
});
closeRemark();
initializeForm();
}原因:.serialize()自动调用了encodeURIComponent方法将数据编码了
解决方法:调用decodeURIComponent(XXX,true);将数据解码