ajax jquery 向服务端发请求中文乱码
发布时间:2020-12-16 00:48:47 所属栏目:百科 来源:网络整理
导读:1 现象 浏览器客户端页面charset是GBK meta http-equiv="content-type" content="text/html; charset=GBK" / 服务端收到乱码 String roleName = request.getParameter(ROLE_NAME_PARAM); 获得的编码是UTF-8 String charset = request.getCharacterEncoding()
1 现象 浏览器客户端页面charset是GBK <meta http-equiv="content-type" content="text/html; charset=GBK" /> 服务端收到乱码 String roleName = request.getParameter(ROLE_NAME_PARAM);
String charset = request.getCharacterEncoding(); 2 修改后,解决乱码 jQuery.ajax({
url: path,type: "POST",dataType:'json',contentType: "application/x-www-form-urlencoded; charset=utf-8",// 增加这一行
data:{'type' : type,'roleName' : roleName,'roleId' : roleId},success:function(json) {
},error:function(er){
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
}); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |