ajax中文乱码问题解决办法

在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");
  }

相关推荐