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")); } }); } }); }
網(wǎng)上說的另一種加contentType的方法貌似不管用,o(︶︿︶)o 唉,還是自己靠譜啊~~
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
以上這篇IE下Ajax提交亂碼的快速解決方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
通達OA 使用Ajax和工作流插件實現(xiàn)根據(jù)人力資源系統(tǒng)數(shù)據(jù)增加OA賬號(圖文詳解)
這篇文章主要介紹了通達OA 使用Ajax和工作流插件實現(xiàn)根據(jù)人力資源系統(tǒng)數(shù)據(jù)增加OA賬號(圖文詳解),需要的朋友可以參考下2016-12-12用ajax實現(xiàn)在單擊事件下加載一個DIV層的腳本
用ajax實現(xiàn)在單擊事件下加載一個DIV層的腳本...2007-11-11