html的我有一个PHP函数来生成图像:从PHP发送图像通过AJAX
function gen_img(){
$image = imagecreate(200,200);
.... //some php codes
header("Content-type:image/jpeg");
imagejpeg($image);
}
// there is no problem when generating image, image generated successfully when i call the function
我知道如何使用这把它放在HTML:
<img id='imageone' src="link to the function">
// the image shown, loaded in the <img> tag, no problem
,但现在我想要使用jquery ajax加载图像,然后将其放入<img>
标记。 有人可以告诉我的方式吗?
为什么这样呢?将html标签放入dom中的那一刻,浏览器会自动加载图像。为什么要经过base64编码图像数据的麻烦? – Tschallacka
我想要刷新图像,并且它是随机图像。它最喜欢验证码 –
啊。那么,我会用base 64编码图像数据。看到我的回答 – Tschallacka