【问题标题】:Page refresh to update table not working in IE 11页面刷新以更新表在 IE 11 中不起作用
【发布时间】:2019-11-07 16:07:48
【问题描述】:

在我的主 asp.net 页面中,我使用了一个使用“datatables.min.js”的数据表以表格格式显示数据。在按钮上单击我会弹出一个 Jquery 模式对话框。添加新数据后,模态对话框关闭,主页面刷新显示新行。这在 Chrome、Firefox 中运行良好。但是当我使用 Internet Explorer 11 尝试时,即使页面刷新,我也看不到新添加的行。我必须再次手动刷新页面才能看到新添加的数据行。

在我的模态对话框代码中,我使用如下所示的“window.location.href”。

        $.ajax({

            type: "POST",
            url: "/Region/Index",
            data: regionFormData,
            success: function () {
                $("#loaderDiv").hide();
                $("#myModal1").modal("hide");
                window.location.href = "/Region/Index";
            }
        });

我试过 location.reload(true);而不是window.locatio.href。但它仍然无法在 IE 11 中运行。

我还尝试在母版页的标题(_Layout.cshtml)中添加 Meta 标签,如下所示

<meta http-equiv="X-UA-Compatible" content="IE=edge;" />

但没有运气。 有没有办法让它在 IE 11 中工作?

【问题讨论】:

  • 尝试在您的$.ajax 请求中设置cache:false。也可以试试window.location.reload() 看看是否有帮助
  • @zgood 如何设置缓存:false。它是 .ajax 调用中的 ine 吗?请告诉我
  • 是的,cache: false 是 ajax 请求中的一个参数。关于如何使用cache:false,您可以参考this thread 中接受的答案。也可以参考this thread之类的在请求中添加时间戳参数的解决方案。
  • @sm101 在您的请求中设置如下:$.ajax({type: "POST",type: "POST",cache: false,data: regionFormData, success: function () { .. }});
  • @zgood set cahe: false, IE 11 问题消失了!惊人的 !我不知道这是一个 IE 11 缓存问题。谢谢!

标签: jquery asp.net-mvc internet-explorer datatables


【解决方案1】:

也许它正在被缓存。也许在 href 部分的末尾放一个随机字符,即:

window.location.href = "/Region/Index?abcd";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 2016-08-15
    • 2015-02-16
    • 2022-01-16
    • 1970-01-01
    相关资源
    最近更新 更多