CharlesDou
CharlesDou

Reputation: 357

How to clear ajax cache in ie and firefox?

I wrote an ajax call to change an image and show it back on the browser when the ajax call succeeds. But the image does not change on IE and Firefox. It works fine on 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'); 
            }
        });

I can see the image has already been changed, but not shown on the browser. Could anyone help me with this?

Upvotes: 0

Views: 1337

Answers (1)

dciso
dciso

Reputation: 1264

The cache false doesn't relate to the image your showing. So for the line

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

Change it to this for example - like you do in your ajax url

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

Upvotes: 1

Related Questions