画像をランダムに生成するphpスクリプトがあります。このようなもの:
<?php
$image = imagecreatetruecolor(400,200);
// process image
// rendering image
header("Content-type: image/jpeg");
imagejpeg($image);
?>
私のhtmlは次のようになります:
<img id="image" src="/models/plugins/image.php"/>
<button id="button">Get new image</button></body>
次に、ボタンのクリックを処理するjqueryファイルがあり、ボタンがクリックされたときに新しいランダム画像が読み込まれます。
$(function(){
$('#button').click(function(){
$.ajax({
url: 'models/plugins/image.php',
success: function(data){
$('#image').html('<img src="' + data + '">')
}
})
})
})
私はfirebugを使用しています。リクエストが実際に送信され、レスポンスが正常に受信されたことがわかりますが、画像は変更されません。
何が間違っているので、どうすれば修正できますか?