ajax中文乱码问题解决办法

傷城~ 2022-04-12 06:38 428阅读 0赞

在IE环境下,ajax传入中文参数乱码解决办法:

$.ajax({
type:’post’,
url:’adddonation_day.do’,
data:’action=isHasFlg&u_name_person=’+encodeURI(encodeURI(inputName)),
cache:false,
success:function(result){
alert(result);
if(result ==’2205’){
alert(“您所输入的姓名已经存在”);
//document.getElementById(“u_name_person”).focus();
//document.getElementById(“u_name_person”).select();
return false;
}
}
});

在页面上连用两个encodeURI

在后头action中

String userName = getString(request, “u_name_person”);
if (!Tools.isEmpty(userName)) {
userName = URLDecoder.decode(userName, “utf-8”);
}

发表评论

表情:
评论列表 (有 0 条评论,428人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Ajax解决中文问题

    Ajax不支持多种字符集,它默认的字符集是UTF-8,所以在应用Ajax技术的程序中应及时进行编码转换,否则对于程序中出现的中文字符将变成乱码。 一般情况下,有以下两种情况可