jquery的ajax向后台提交时,乱码的解决方案

1. 可以给每个参数加上encodeURIComponent(),然后在后台获得参数后用URLDecoder.decode(string, 'utf-8')解码。

 

2. 后台不用解码。

              $.ajax({
                   url : '',
                   type : 'post',
                   contentType: "application/x-www-form-urlencoded; charset=utf-8", 
                   data : {
                       serialNum : serialNum,
                       conditionString : conditionString,
                   },
                   success : function(msg){
                       alert(msg);
                   },
                   error : function(msg){
                       alert(msg);
                   }
               });

 

posted @ 2013-12-31 16:37  火光闪耀  阅读(227)  评论(0编辑  收藏  举报