I have created ajax function like this...In this I will get the value from run time and i need to return the photo according to that value..In success function i need to display that image in particulat div
var num=document.getElementById('number').value;
$.ajax({
    url:"image.php?val="+num,
    contentType: "image/png",
    success:function(img)
    {
        $('#image').html('<img src="data:image/png;base64,' + img + '" />');
    }
    });
image.php page
$sql_sub = select_query("select pic from  photo  where picnum=".$_GET['val']."");
$img = $sql_sub[0][0]->load();
header("Content-type: image/png");
ob_start();
imagepng($img);
echo "data:image/png;base64,", base64_encode(ob_get_clean());
 
     
    