function updateStatus() {
var data = {};
var str = $("#ver-form").serialize();
str = decodeURIComponent(str,true);
data.remark = str + "&eventId=" + eventId;
$.ajax({
type: "POST",
url: '${ctx}/event/updateRemarkEvent',
data: data,
async: false,
dataType: "json",
success: function (data, textStatus) {
},
contentType: "application/x-www-form-urlencoded"
});
closeRemark();
initializeForm();
}
原因:.serialize()自动调用了encodeURIComponent方法将数据编码了
解决方法:调用decodeURIComponent(XXX,true);将数据解码
本文介绍了一个关于使用jQuery的.serialize()方法导致的数据编码问题及解决方案。当使用此方法提交表单数据时,它会自动调用encodeURIComponent进行编码,这可能与服务器端的需求不符。文章提供了解决方案,即通过调用decodeURIComponent来对数据进行解码,确保数据格式正确。
602

被折叠的 条评论
为什么被折叠?



