【问题标题】:changing data behind the path of an image - jquery is only displaying the old image更改图像路径后面的数据 - jquery 仅显示旧图像
【发布时间】:2011-06-11 14:48:26
【问题描述】:

想象一下您在 Facebook 上的个人资料。更改头像时,您选择一张新图片,对其进行裁剪,然后将其保存。之后,新头像会显示在您的个人资料中。

我希望在我的网站上提供相同的服务 - 一切正常。

但是:我无法在创建后立即显示新的和(!)裁剪的头像(使用 php)。我只能显示新的,但未裁剪的。刷新我的网站后,一切正常。

$("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", { bild: bild, 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 = ""; } });

我只是不知道该站点如何显示未裁剪的头像,因为它不再存在。它已被裁剪后的替换。

非常感谢!

本杰明

【问题讨论】:

    标签: ajax image jquery jcrop


    【解决方案1】:

    问题是你的头像图片被缓存了,所以尝试添加一个带有图像名称的随机参数

    加载中var i=1;
    关于头像更换i++;
    并设置img src ="imgpath?random="+i

    【讨论】:

    • 对不起,我明白你的意思,但我并没有完全理解它。我必须在哪里添加随机参数?在 php 文件中?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-20
    • 2019-01-13
    • 2017-07-08
    • 2016-03-09
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    相关资源
    最近更新 更多