jquery $.post ie获取不到返回值的解决方法

来源:互联网 发布:情趣用品淘宝店简介 编辑:程序博客网 时间:2024/05/16 14:07

1、后台环境:php

2、前台html jquery


问题:用jquery获取返回值的时候失败,用抓包工具,或者浏览器本身的调试工具,都可以看到respones的返回,但是jquery进行输出为undefined;


js代码如下

$.post("/android/?action=giftcode", { control: 'getOne', ids: ids }, function (res) {                console.log(res);});

console.log的结果 在ie浏览器下 都为undefined




响应中 可以正确获取的文本内容


响应header中的Content-Type 为 text/html


莫名奇妙的结果


解决方法:

在服务端中需要手动指定一下头部。

这里以php为例:

header("Content-Type: text/html; charset=UTF-8");

问题解决

0 0