在图像路径后面更改数据-jQuery仅显示旧图像

问题描述

| 想象一下您在Facebook上的个人资料。更改头像时,请选择一张新图片,对其进行裁剪,然后对其进行保护。之后,新的头像将显示在您的个人资料中。 我想在我的网站上提供相同的服务-一切正常。 但是:创建后(使用PHP),我无法立即显示新的and(!)裁剪的头像。我只能显示新的,但未裁剪的。刷新我的网站后,一切正常。 $(\“ div#button2 \”)。click(function(){
//Thumbnail is created externally with PHP
    //the name of the new cropped avatar is the same like the uncropped one
    //i just change the picture,but the url is the same!
$.post(\"upload_thumbnail.PHP\",{
    bild: bild,format: format,x: x,y: y,w: w,h: h
});

//delete the old avatar
$.post(\"upload_loeschen.PHP\",{
    bild: bildalt
});

//save the url of the new cropped avatar in the database
$.post(\"upload_update.PHP\",laden_nr: \"1\"
});


//close my imageeditor
$(\"div#bildeditor\").hide();

jcrop_api.destroy();
$(\"#cropBox\").attr(\"src\",\"\");
$(\"#preview\").attr(\"src\",\"\");

    //If there is a new avatar,display it!!! -> and here only the uncropped is displayed
    if(bild != \"\") {
    $(\"img#logo\").attr(\"src\",bild);
    bild = \"\";      
}
    });
我只是不知道该网站如何显示未裁剪的头像,因为它不再存在。取而代之的是它。 非常感谢你! 本杰明     

解决方法

        问题是您的头像图片已被缓存,因此请尝试添加带有图片名称的随机参数 负载
var i=1;
在化身上改变
i++;
然后设置the3ѭ