欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

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

程序员文章站 2022-06-06 10:10:25
...
下面我就为大家带来一篇IE下Ajax提交乱码的快速解决方法。现在就分享给大家,也给大家做个参考。

哈哈,试了这么多还是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"));
	}
  
});
    }
  });
}

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

Ajax表单异步上传文件实例代码

下拉菜单的级联操作

Ajax实现省市区三级级联

以上就是IE下Ajax提交乱码的快速解决方法的详细内容,更多请关注其它相关文章!

相关标签: Ajax ie 解决