ajax获取数据中文乱码问题最简单的完美解决方案

[ 2015-11-28 16:46:44 | 作者: admin ]
字号: | |
p.s. 发现提交的编码都是 utf-8 ,指定为gb2312无用,在gbk网页中,也只能对中文先编码后解码了

使用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
});
[最后修改由 admin, 于 2015-11-28 16:49:10]
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2299

这篇日志没有评论。

此日志不可发表评论。