下面小编就为大家带来一篇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"));
}
});
}
});
}
网上说的另一种加contentType的方法貌似不管用,o(︶︿︶)o 唉,还是自己靠谱啊~~
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
以上这篇IE下Ajax提交乱码的快速解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程学习网。
编程基础网
本文标题为:IE下Ajax提交乱码的快速解决方法
基础教程推荐
猜你喜欢
- ajax异步加载图片实例分析 2022-12-18
- vue在install时node-sass@4.14.1 postinstall:node scripts/build.js错误解决 2023-07-09
- html网页中使用希腊字母的方法 2022-09-21
- JavaScript函数this指向问题详解 2023-08-12
- 使用HTML5中postMessage知识点解决Ajax中POST跨域问题 2022-10-17
- 【vue】三种获取input值的写法 2023-10-08
- JavaScript开发简单易懂的Svelte实现原理详解 2023-08-12
- Ajax实现简单下拉选项效果【推荐】 2022-12-28
- AJAX实现数据的增删改查操作详解【java后台】 2023-02-23
- Ajax实现关键字联想和自动补全功能及遇到坑 2023-02-23
