little_bill 发表于 2013-1-24 07:16:31

jquery 解决ie下ajax post 提交乱码

因为jquery ajax是使用utf-8来编码发送数据的,ie在发送时却没加上charset=utf-8,从而导致乱码(IE默认使用iso-8859-1编码)

contentType: "application/x-www-form-urlencoded; charset=utf-8",

$.ajax({type:"post",url:"ajax.jsp?m=openbaiduBatchIPData",data:"ipData="+ipData,dataType:"html",contentType: "application/x-www-form-urlencoded; charset=utf-8",async: false,success:function(data){if(data.length > 0){$("#showBatchIPAdress").html(data);}else{$("#showBatchIPAdress").html('没有找到ip地址');}},error:function(){$("#showBatchIPAdress").html('程序出问题了');}});
页: [1]
查看完整版本: jquery 解决ie下ajax post 提交乱码