当前位置: 移动技术网 > IT编程>脚本编程>Ajax > IE下Ajax提交乱码的快速解决方法

IE下Ajax提交乱码的快速解决方法

2017年12月08日  | 移动技术网IT编程  | 我要评论
哈哈,试了这么多还是encodeuricomponent管用啊!!!! 在汉字的位置加个保护措施:encodeuricomponent(parentid) fu

哈哈,试了这么多还是encodeuricomponent管用啊!!!!

在汉字的位置加个保护措施:encodeuricomponent(parentid)

function loadcity(parentid) {
	var city = '${hotel.city}';
	
  $.ajax({
    url: './listcity.jspx?prov='+ encodeuricomponent(parentid),
    type: 'get',
    datatype: 'json',
    timeout: 5000,
    error: function() { alert('加载城市列表失败!'); },
    success: function(msg) {
$("#city").empty();
$.each(eval(msg), function(i, item) {
	if(item.city ==city){
		$("<option value='" + item.city + "' selected = 'selected'>" + item.city + "</option>").appendto($("#city"));
	}else{
		 $("<option value='" + item.city + "'>" + item.city + "</option>").appendto($("#city"));
	}

  
});
    }
  });
}

网上说的另一种加contenttype的方法貌似不管用,o(︶︿︶)o 唉,还是自己靠谱啊~~

contenttype: 'application/x-www-form-urlencoded; charset=utf-8',

以上这篇ie下ajax提交乱码的快速解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网