Форумы / Craftwork / Client-side / [solved] Construct img tag with javascript and php

GHengeveld
#12494 14.05.2009 07:24
Why not use jQuery's built in ajax functions? You're reinventing the wheel here...
$.get(url, data, callback, type) will replace basically the entire code above.

Still, I believe there are more efficient ways to load a dynamic image. For example, you could use php to generate an image using the GD library. That way you won't need any javascript at all.

<?php
header("Content-type: image/jpeg");
$imageurl = 'http://www.huddletogether.com/projects/lightbox2/images/image-2.jpg';
$image = imagecreatefromjpeg($imageurl);
@imagejpeg($image);
?>

You can do whatever you want in there with php. You could even dynamically set the content type. Result of the code above is here.
Отредактировано: Koradhil (14.05.2009 07:42, 15 лет назад)