您当前的位置:首页 > 网站建设 > ajax
| php | asp | css | H5 | javascript | Mysql | Dreamweaver | Delphi | 网站维护 | 帝国cms | React | 考试系统 | ajax | jQuery | 小程序 |

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

51自学网 2022-02-21 10:53:10
  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"));	}  });    }  });}

网上说的另一种加contentType的方法貌似不管用,o(
下载地址:
ajax设置async校验用户名是否存在的实现方法
Ajax表单异步上传文件实例代码(包括文件域)

万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。