开发者

Is there a better way to update an img tag calling a PHP page?

I'm using jcrop and after a user crps an image I make a call to a php page that returns the img tag like so:

$.get("get_profile_picture.php", function(data) {
    $('#profile_photo_id'开发者_JS百科).html(data);

    jQuery('#cropbox').Jcrop({
        onChange: showPreview,
        onSelect: showPreview,
        aspectRatio: 1
    });        
});

$.get("get_profile_thumb.php", function(data) {
    $('#profile_thumb_id').html(data);
});

This works fine but my concern is that I'm making two additional calls everytime a user uploads a new image. The img src code returned from get_profile_picture.php looks like this:

<img src=<?php echo(getProfileThumb($user_id, FALSE)) ?> id="cropbox" />

I'm curious to know if there is a more elegant solution. I've tried setting the attr 'src' tag for the "cropbox" id but it needs to execute the PHP code inside first. Any thoughts or suggestions?


if you want to get rid of the second GET you could use the loaded img tag (and image of course) from the first GET and resize it with css to the size of your tumbnail.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜