Setting the cache in jQuery $.post() to be false?

I have this code:

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

I understand that $.post is just another name for $.ajax. And I know $.ajax has caching on by default. I want it to be uncached. How can I do that?


$.post is not cached.

Pages fetched with POST are never cached, so the cache and ifModified options in jQuery.ajaxSetup() have no effect on these requests.

From http://api.jquery.com/jQuery.post/


Partly right, Daniel A. White!

On devices running iOS6 and Safari, POST is also cached.

What you can do is the following:

$.ajaxSetup({
   type: 'POST',
   headers: { "cache-control": "no-cache" }
});

You mention $.ajax

You can turn caching off for ajax like this:

$.ajax({
        url: "/myURL?",
        cache: false,
    });
链接地址: http://www.djcxy.com/p/55712.html

上一篇: 只允许通过本地服务器上的ajax访问PHP文件

下一篇: 在jQuery $ .post()中设置缓存为false?