有没有更好的方法来更新调用PHP页面的img标记?
我正在使用jcrop,在用户crps一个图像后,我调用一个php页面,该页面返回img标记,如下所示:有没有更好的方法来更新调用PHP页面的img标记?,php,jquery,image,jcrop,Php,Jquery,Image,Jcrop,我正在使用jcrop,在用户crps一个图像后,我调用一个php页面,该页面返回img标记,如下所示: $.get("get_profile_picture.php", function(data) { $('#profile_photo_id').html(data); jQuery('#cropbox').Jcrop({ onChange: showPreview, onSelect: showPreview, aspectR
$.get("get_profile_picture.php", function(data) {
$('#profile_photo_id').html(data);
jQuery('#cropbox').Jcrop({
onChange: showPreview,
onSelect: showPreview,
aspectRatio: 1
});
});
$.get("get_profile_thumb.php", function(data) {
$('#profile_thumb_id').html(data);
});
这很好,但我担心的是,每次用户上传新图像时,我都会打两个额外的电话。从get_profile_picture.php返回的img src代码如下所示:
<img src=<?php echo(getProfileThumb($user_id, FALSE)) ?> id="cropbox" />
id=“cropbox”/
我很想知道是否有更优雅的解决方案。我已经尝试过为“cropbox”id设置attr'src'标记,但是它需要首先执行里面的PHP代码。有什么想法或建议吗?如果你想摆脱第二个get,你可以使用第一个get中加载的img标签(当然还有图像),并使用css将其调整为tumbnail的大小。我做了类似的事情,更改了返回的数据,解决了我的问题。我现在只需要打一次电话。谢谢