【问题标题】:Nested Ajax Get request not firing in IE11嵌套的 Ajax Get 请求未在 IE11 中触发
【发布时间】:2016-11-01 16:20:23
【问题描述】:

我在 IE11 中遇到问题,但在 Chrome 或 Firefox 中没有问题。我有一个 Ajax Get 请求嵌套在一个似乎没有触发的 Ajax Post 请求的 Success 函数中。但是,在开发人员工具打开的情况下,它会触发并按预期运行。为什么会这样?

            $.ajax({
                url: urls.firstUrl,
                type: 'POST',
                data: { itemId: itemId },
                success: function (data) {
                    $('#aDiv').html(data);
                    $.ajax({
                        url: urls.secondUrl,
                        type: 'GET',
                        success: function (data) {
                            $('#aDiv').html(data);
                        },
                        error: function (xhr, status, error) {
                            showErrorAlert(xhr, status, error);
                        }
                    });
                },
                error: function (xhr, status, error) {
                    showErrorAlert(xhr, status, error);
                }
            });

【问题讨论】:

  • 'Doesn't seem to fire' 不会削减它,添加一些 alert()'s 来测试 IE11 中的行为。让其他人更容易提供帮助。

标签: javascript ajax internet-explorer-11 developer-tools


【解决方案1】:

在短时间内触发的请求中,IE11 会为前一个请求使用缓存。我找到了解决方案,在 IE11 中你必须使用属性CACHE: FALSE 进行 ajax 请求,如下所示:

$.ajax({
  url: "test.html",
  cache: false
})
  .done(function( html ) {
    $( "#results" ).append( html );
  });

【讨论】:

    猜你喜欢
    • 2020-03-03
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多