`

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('程序出问题了');
	}
});


分享到:
评论
Global site tag (gtag.js) - Google Analytics