【问题标题】:IE9 Ajax Succeeds but no response bodyIE9 Ajax 成功但没有响应体
【发布时间】:2012-11-21 19:18:05
【问题描述】:

我有一个简单的 ajax 请求,它适用于除 IE9 之外的所有现代浏览器(当然)。在 IE9 中,响应返回为 200,成功函数触发,但没有返回数据。

这里是js:

function getMapPins(section){
    $('.spinnerBG').fadeIn('fast');
    $.ajax({
        type: 'POST',
        url: '/ourprojects_ajax.html',
        data: {'map_section':section},
        cache:false,
        success: function(data){
            //alert(data);
            $('#mapPins').append(data);
            createPins(section);
        }
    });

}

只是为了确保它不是 PHP:

<?php echo '<p>why won't this damn thing work in IE9</p>'; ?>

有什么想法吗?

【问题讨论】:

  • 在IE的开发者工具中查看响应体是完全空的,响应头Content-Length为0
  • 我知道你的 ajax 调用中已经有 cache:false 了.. 但是为了傻笑试试这个 - 在你所有的 js 代码把它放在那里之前 $.ajaxSetup({cache:false});跨度>

标签: php jquery ajax internet-explorer-9


【解决方案1】:

似乎有一个PARSE ERROR:

<?php echo '<p>why won't this damn thing work in IE9</p>'; ?>

应该是:

<?php echo '<p>why won\'t this damn thing work in IE9</p>'; ?>

如果您关闭了错误,那么您将不会得到响应,因为页面将是空白的。

【讨论】:

  • 如何启用错误?当抛出异常时,我的页面变为空白。它是 php.ini 中的配置吗?
  • 是的。或者您可以将error_reporting(E_ALL) 添加到您的 php 文件的顶部
  • 没有骰子。以前响应是一些更复杂的 html。我已经尝试过 addlashes() 和 htmlspecialchars()。即使是简单的字符串“成功”也不会回来。
  • 您确定 PHP 正在服务器上运行吗?您的 PHP 设置是否使用 .html 作为文件扩展名?
  • 是的,除了 IE9 之外,这绝对适用于任何地方。我可以访问 /ourprojects_ajax.html 页面并查看响应,因此我知道 php 脚本正在运行。
猜你喜欢
  • 1970-01-01
  • 2016-11-09
  • 2016-05-13
  • 2011-09-22
  • 1970-01-01
  • 2019-04-22
  • 2016-01-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多