做项目的时候,会遇到这种情况,通过ajax从后台获取的数据在chrome上显示的是最新的,而在IE上却是以前的数据,这是为什么呢,在我百般调试下终于发现原来是因为IE的ajax缓存的原因,于是加上这段代码就ok了!

// 设置Ajax操作的默认设置
$.ajaxSetup({
    cache: false,
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        if (typeof (errorThrown) != "undefined")
            $.messager.alert(g_MsgBoxTitle, "调用服务器失败。<br />" + errorThrown, 'error');
        else {
            var error = "<b style='color: #f00'>" + XMLHttpRequest.status + "  " + XMLHttpRequest.statusText + "</b>";
            var start = XMLHttpRequest.responseText.indexOf("<title>");
            var end = XMLHttpRequest.responseText.indexOf("</title>");
            if (start > 0 && end > start)
                error += "<br /><br />" + XMLHttpRequest.responseText.substring(start + 7, end);

            $.messager.alert(g_MsgBoxTitle, "调用服务器失败。<br />" + error, 'error');
        }
    }
});

 

相关文章:

  • 2021-08-16
  • 2022-12-23
  • 2021-11-17
  • 2021-04-18
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-02-19
  • 2022-12-23
  • 2021-11-17
  • 2021-11-30
相关资源
相似解决方案