Im getting link instead of image.
$.ajax({
type: "GET",
url: "image.php",
contentType: "image/png",
success: function(result){
$('.image').text(result);
}
});
$image = "http://4.bp.blogspot.com/-JOqxgp-ZWe0/U3BtyEQlEiI/AAAAAAAAOfg/Doq6Q2MwIKA/s1600/google-logo-874x288.png";
echo '<img src="'.$image.'"></img>';
<div class="image"></div>
Returns text instead of image:
<img src="http://4.bp.blogspot.com/-JOqxgp-ZWe0/U3BtyEQlEiI/AAAAAAAAOfg/Doq6Q2MwIKA/s1600/google-logo-874x288.png"></img>
Replace
$('.image').text(result);
with
$('.image').html(result);
It will work fine. text()
outputs string and html()
outputs html markup
Try:
$.ajax({
type: "GET",
url: "image.php",
contentType: "image/png",
success: function(result){
$('.image').html(result); //change text to html
}
});
Text is used to inject a text node into the element, which isn't interpreted as html. The html() method writes html into the element and is interpreted as such.