使用jQuery表单缓存IE图像:强制重新加载图像



我有以下代码:

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

在IE中,图像会被缓存而不会重新加载,我想强制它刷新。问题是我在PHP文件中重命名了图像,所以我想知道如何在加载图像后添加一个参数(?date)

试试这个:

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

最新更新