将jQuery $ .post()中的缓存设置为false?

AKo*_*Kor 10 jquery

我有这个代码:

$.post("php/tagNotifUnsub.php", $("#tagNotifUnsub").serialize(), function(){ 
            $('#tagSubDiv').load('tags.php #tagSubDiv', function(){$( "button, input:submit, input:button, a#jql, input:radio" ).button();});      
        });
Run Code Online (Sandbox Code Playgroud)

我知道$ .post只是$ .ajax的另一个名字.我知道默认情况下$ .ajax有缓存.我希望它被解除.我怎样才能做到这一点?

Dan*_*ite 30

$.post 没有缓存.

使用POST获取的页面永远不会被缓存,因此jQuery.ajaxSetup()中的缓存和ifModified选项对这些请求没有影响.

来自http://api.jquery.com/jQuery.post/

  • 嗯这不完全正确,IOS 6上的Safari缓存了POST请求,它很疯狂,但确实如此.[http://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results] (4认同)

Eli*_*ias 16

部分正确,丹尼尔A.怀特!

在运行iOS6和Safari的设备上,POST也会被缓存.

你能做的是以下几点:

$.ajaxSetup({
   type: 'POST',
   headers: { "cache-control": "no-cache" }
});
Run Code Online (Sandbox Code Playgroud)