很多小伙伴們在使用IE下是不是都遇到過AJAX提交亂碼的情況呢?當我們遇到IE下Ajax提交亂碼怎么解決是不是很多小伙伴都覺得困擾,那么下面我們就一起去看看IE下Ajax提交亂碼的解決方法。
哈哈,試了這么多還是encodeURIComponent管用?。。。。?/p>
在漢字的位置加個保護措施: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提交亂碼怎么解決就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持錯新技術頻道。
新聞熱點
疑難解答
圖片精選