【问题标题】:MVC Action not getting called in Internet explorer and Mozilla firefox在 Internet Explorer 和 Mozilla firefox 中未调用 MVC 操作
【发布时间】:2018-11-01 19:27:12
【问题描述】:

美好的一天 在我的应用程序中,每当我按下浏览器后退按钮时,我都想获取数据 我在谷歌 chrome 浏览器中获取数据它工作正常 但是当我在 Inter explorer 11 和 Mozilla Firefox 中进行测试时,它不起作用 未调用该操作 正在执行警报,但未调用操作 当我在任何浏览器中测试时,只要用户按下返回按钮,就会触发警报

bajb_backdetect.OnBack = function () {

            alert(document.referrer);

           var url = "/Login/GetID";
                $.getJSON(
                    url,
                    null,
                    function (data) {
                        alert(data);
                    });
        }

【问题讨论】:

  • 你不应该在浏览器中乱用后退按钮。虽然有可能,但并非所有浏览器都能很好地处理它,并且可能会疏远您的用户。
  • 是的,但我在 IE、Safari、opera、Google chrome、Mozilla 中进行了测试
  • 如果你测试过并且工作正常,那是什么问题?
  • My Action("/Login/GetID") GetID 没有被调用,但提醒我正在被触发
  • 它可能被缓存或类似的东西。你试图做的不是一个好主意,从长远来看会给你带来更多麻烦。

标签: ajax asp.net-mvc-4 google-chrome mozilla internet-explorer-11


【解决方案1】:

您可以通过在每次调用中添加“cache: false”来防止这种行为

$.ajaxSetup({
    cache: false
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多