IE image caching with jQuery form: Force image reloading

↘锁芯ラ 提交于 2019-12-25 05:33:23

问题


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:


Try this:

var counter = 0;
...
$("#imageBox").html('<img src="img/loader.gif?c='+counter+'" alt="Uploading...."/>');
counter++';


来源:https://stackoverflow.com/questions/9207090/ie-image-caching-with-jquery-form-force-image-reloading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!