欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

IE下Ajax提交亂碼的快速解決方法

 更新時(shí)間:2016年08月25日 09:52:12   投稿:jingxian  
下面小編就為大家?guī)硪黄狪E下Ajax提交亂碼的快速解決方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

哈哈,試了這么多還是encodeURIComponent管用?。。。。?/p>

在漢字的位置加個(gè)保護(hù)措施: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"));
	}

  
});
    }
  });
}

網(wǎng)上說的另一種加contentType的方法貌似不管用,o(︶︿︶)o 唉,還是自己靠譜啊~~

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

以上這篇IE下Ajax提交亂碼的快速解決方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論