IE image caching with jQuery form: Force image rel

2019-08-23 09:56发布

I have the following code:

$('#imageform').submit(function() {
    $("#imageBox").html('');
    $("#imageBox").html('<img src="img/loader.gif" alt="Uploading...."/>');
    $("#imageform").ajaxSubmit(
    {
        target: '#imageBox',
        resetForm: true
    });
    return false;
});

In IE, the image will be cached and not reload, I wanted to force it to refresh. The problem is that I rename the image in a PHP file, so I wanted to know how to add a paramter (?date) AFTER the image is loaded.

1条回答
叛逆
2楼-- · 2019-08-23 10:45

Try this:

var counter = 0;
...
$("#imageBox").html('<img src="img/loader.gif?c='+counter+'" alt="Uploading...."/>');
counter++';
查看更多
登录 后发表回答