javascript - 缓存:false in ajax call attach a value with URl

标签 javascript jquery ajax caching backbone.js

如果我使用以下方法将 AJAX 缓存设置为 false:

$.ajaxSetup ({
cache: false });

然后我生成的 AJAX URL 将字符 &_=1381901096821 添加到末尾,以便浏览器(尤其是 IE)将其视为新页面请求。

调用的结果是: 例如 =1381901096821">http://MyServer/authcheck?=1381901096821

但我不希望该值附加在 URL 上。有什么办法可以去掉吗?

提前致谢。

最佳答案

您可以将缓存设置为 true:

$.ajaxSetup ({
    cache: true
});

然后手动添加无缓存 header :

$.ajaxSetup({
    beforeSend: function (xhr)
    {
        xhr.setRequestHeader("Cache-Control", "no-cache");
        xhr.setRequestHeader("Pragma", "no-cache");
    },
});

关于javascript - 缓存:false in ajax call attach a value with URl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19396014/

相关文章:

c# - 检测selenium中的ajax请求

javascript - 模糊 testcafe 中的输入字段

javascript - 将分层 JSON 文件转换为分层 jQuery div

javascript - jQuery:为什么我无法访问滚动事件中的事件对象?

jquery - Bootstrap 选项卡 - 隐藏选项卡的内容仍然可编辑

jquery - 如何从 byte[] 中的 webmethod 下载 javascript 或 jquery 中的文件?

javascript - 多个 DropDownLists - 使用 ID 调用单个函数

javascript - 使用 getusermedia 显示 html 视频

javascript - PHP函数与jquery按类动态随机插入记录

python - 将 Django UserCreationForm 的密码验证错误从密码 2 移至密码 1