hope you can help me, i have PHP script that generate image(get image using curl) it is call via ajax,when i directly access the php script(not using ajax) image is successfully generated but when call via ajax it display garbled text. Do you know the reason of this?
PHP SCRIPT:
header('Content-Type: image/jpeg');
header('Content-Length: ' . get_size($songname));
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_HTTPGET,1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_exec($ch);
curl_close($ch);
Javascript:
$.post(baseUrl+"getphoto.php",{photo:path }).done(function( data ) {
console.log('#thumb_'+id);
//garbled text appear on firebug
}});