ajax获取数据中文乱码问题最简单的完美解决方案
来源:
中文源码网 浏览:137 次 日期:2024-05-09 21:10:17
【下载文档: ajax获取数据中文乱码问题最简单的完美解决方案.txt 】
ajax获取数据中文乱码问题最简单的完美解决方案
使用scriptCharset即可解决问题,用contentType就不一定可以了。
复制代码 代码如下:
$.ajax({
url: testUrl,
dataType: 'jsonp',
type: 'post',
scriptCharset: 'utf-8'
});
上面的解决方案是最完美的,另外也附上网上的解决方式吧,是用contentType来处理的
复制代码 代码如下:
jQuery(form).ajaxSubmit({
url: "ajax.aspx?a=memberlogin",
type: "post",
dataType: "json",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: showLoginResponse
});
虽然也可以用,但是不推荐给大家哈。