【问题标题】:jquery $.post not working in iejquery $.post 在 ie 中不起作用
【发布时间】:2014-03-05 10:26:52
【问题描述】:

我在通过 $.post 发回数据时遇到问题。 这是我的 $.post 的 JS 代码:

$.ajaxSetup({ cache: false });
$.post(
    "run.php",
    { q: cmd , dir: dir },
    function(data, status){
        $("#results").html(data);
    }
);

在 run_php 中:

// I run python code using q and dir. It works fine.
foreach ($fileArr as $key => $value) {
    echo '<p><a href="'.$default_dir.'/'.$value.'" target="_blank">'.$value.'</a></p>';
}
// But here it doesn't return any value.

它适用于 Chrome 和 Firefox,不适用于 IE。可能是什么问题呢? 这段代码非常简单,但我挣扎了好几个小时。 提前致谢。

【问题讨论】:

  • 您是否检查过控制台是否有任何错误,或者查看返回的响应是什么?
  • 如果您使用 jQuery,您使用的是哪个版本的?较新的版本删除了一些 IE
  • 当我将 .fail 添加到 .post 时,xhr.responseText 为空。
  • 我正在使用 jquery 1.10.2 @AndyHolmes
  • 嗯,是的,你需要使用 1.9,因为较新的版本已经删除了一些 ie 版本

标签: javascript jquery ajax post


【解决方案1】:

jquery 1.9 version 用于IE 作为不支持IE&lt;=9 的最新版本的jquery

阅读jquery 2.0 release

【讨论】:

  • OP 说他使用的是 1.10.2,所以这不是问题(我不是反对者)。
  • 我不是反对者。但我想知道为什么 IE 版本以下不支持 jquery 1.10。所有 jquery 1.x 都支持低版本的 IE 浏览器吧?只有jquery 2.0不支持IE9以下版本
  • 我没有投反对票,但这是不正确的——或者充其量是不完整的。 1.x 流(目前最高 1.11.0)支持旧版 IE。 2.x 流(当前为 2.1.0)不支持旧版 IE。最新的 1.x 与最新的 2.x 具有相同的 API。
  • @Vucko 你是对的。只有 jquery 2.0 不支持低版本的 IE。
猜你喜欢
  • 2012-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-07
  • 2011-02-13
  • 2012-09-21
  • 2011-09-01
相关资源
最近更新 更多