【问题标题】:How to clear ajax cache in ie and firefox?如何清除ie和firefox中的ajax缓存?
【发布时间】:2013-01-03 13:22:31
【问题描述】:

我编写了一个 ajax 调用来更改图像并在 ajax 调用成功时将其显示在浏览器上。但图像在 IE 和 Firefox 上没有变化。它在 Chrome 上运行良好。

var url =  "/store/artwork/index/renderSVGFile?"+"docID=<?php echo $docID ?>&unique="+(new Date()).getTime();
    jQuery('*').css('cursor', 'wait');
        jQuery.ajax({
            url: url,
            cache:false,
            type: "POST",
            data: {},
            success: function(data) {
                jQuery('#product-img-template').html("<img src='/path/to/image/<?php echo $docID ?+>.png' />");
                jQuery('#product-img-template').css("position", "relative");
                jQuery('#product-img-template').css("top","-430px");
                jQuery('#product-img-template').css("left","-7px");
                jQuery('#product-img-template').css("height","400px");
                jQuery('#product-img-template').css("margin-bottom","-350px");
                jQuery('#product-img-template').css("z-index","20");
                jQuery('*').css('cursor', 'auto'); 
            },
            failure: function(data) {
                 jQuery('*').css('cursor', 'auto'); 
            }
        });

我可以看到图像已经更改,但没有显示在浏览器上。谁能帮我解决这个问题?

【问题讨论】:

    标签: jquery caching browser-cache


    【解决方案1】:

    缓存 false 与您显示的图像无关。所以对于这条线

    jQuery('#product-img-template').html("<img src='/path/to/image/<?php echo $docID ?+>.png' />");
    

    例如将其更改为此 - 就像您在 ajax url 中所做的那样

    jQuery('#product-img-template').html("<img src='/path/to/image/<?php echo $docID ?+>.png?" + (new Date()).getTime() + "' />");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-25
      • 2017-05-28
      • 1970-01-01
      • 1970-01-01
      • 2017-01-06
      • 2017-06-19
      • 1970-01-01
      相关资源
      最近更新 更多