jQuery.ajax() - IE9中返回的未定义数据

Vex*_*tor 8 ajax jquery internet-explorer-9

我有一个非常简单的代码:

$.ajax({
  cache: false,
  dataType: 'html',
  complete: function(jqXHR){
    console.log(jqXHR.responseText);
  },
  success: function(data){
    console.log(data);
  },
  url: 'http://follows.pl/pages/ajaxtest'
});
Run Code Online (Sandbox Code Playgroud)

它返回ff,chrome和IE8中的一些文本,但在IE9中它显示两次"undefined".

我在IE9中查看了开发人员工具,它显示了正常的响应,因此请求工作正常,响应很好,但变量未定义

回复标题:

Response    HTTP/1.1 200 OK
Cache-Control   no-cache
Content-Type    text/html; charset: UTF-8
Pragma  no-cache
Run Code Online (Sandbox Code Playgroud)

响应

string(4) "test"
Run Code Online (Sandbox Code Playgroud)

Syn*_*hro 7

我怀疑这是你的问题:

Content-Type    text/html; charset: UTF-8
Run Code Online (Sandbox Code Playgroud)

该值未正确格式化(charset错误后的':')并且IE9不喜欢它,但是默默地失败而不是说有用的东西.试试这个:

Content-Type:    text/html;charset=utf-8
Run Code Online (Sandbox Code Playgroud)


Roy*_*mir 0

尝试这个 :

$.ajax({
  cache: false,
  dataType: 'html',
  complete: function(data){
    console.log(data);
  },
  success: function(data){
    console.log(data);
  },
  url: 'http://follows.pl/pages/ajaxtest'
});
Run Code Online (Sandbox Code Playgroud)

注意

在成功函数中

 success: function (data, textStatus, jqXHR)
Run Code Online (Sandbox Code Playgroud)

对象就是third论证。

您实际上是通过访问那里不存在的属性来响应数据的。

功能也很齐全

 complete: function (jqXHR, complete_textStatus)
Run Code Online (Sandbox Code Playgroud)

这里的对象是first地方!

你必须记住地点。