jQuery.get() is a shorthand for jQuery.ajax() with a get call. But when I set cache:false in the data of the .get() call, what is sent to the server is a parameter called cache with a value of false. While my intention is to send a timestamp with the data to the server to prevent caching which is what happens if I use cache: false in jQuery.ajax data. How do I accomplish this without rewriting my jQuery.get calls to jQuery.ajax calls or using

$.ajaxSetup({
    // Disable caching of AJAX responses
    cache: false
});

update: Thanks everyone for the answers. You are all correct. However, I was hoping that there was a way to let the get call know that you do not want to cache, or send that value to the underlying .ajax() so it would know what to do with it.

I a. looking for a fourth way other than the three ways that have been identified so far:

  1. 通过ajaxSetup在全局实现

  2. Using a .ajax call instead of a .get call

  3. 通过将保存时间戳的新参数添加到.get调用来手动执行此操作.

我只是认为应该将此功能内置到.get调用中.

推荐答案

To me, the correct way of doing it would be the ones listed. Either ajax or ajaxSetup. If you really want to use get and not use ajaxSetup then you could create your own parameter and give it the value of the the current date/time.

然而,我会质疑您不使用其他方法之一的动机.

Jquery相关问答推荐

JQuery AJAX 成功事件未触发

哪个 JQuery Select 器会排除与给定 Select 器匹配的父项的项目?

用 JS 触发 CSS 悬停

bootstrap 模式中的自动完成问题

提高 jQuery Select 器性能的好方法?

$.post 和 $.ajax 之间的区别?

jQuery.parseJSON 单引号与双引号

如何在 jQuery 中获取浏览器滚动位置?

jQuery: Select 属性大于值的所有元素

JQuery 仅在 Rails 4 应用程序中的页面刷新时加载

window.onbeforeunload 和 window.onunload 在 Firefox、Safari、Opera 中不起作用?

如何在 Jquery 中通过索引获取子元素?

按百分比zoom div的内容?

如何知道字体(@font-face)是否已经加载?

如何获取 onclick 调用对象?

我可以限制 JavaScript 中数组的长度吗?

使用 jquery 通过文本设置下拉值

禁用 jquery Select 的下拉菜单

变量首字母大写

检测 jQuery UI 对话框是否打开