Hitu Bansal Hitu Bansal - 2 years ago 103
Ajax Question

Want to show image , after getting image name using ajax, not want to return html

I want to show image after getting response from ajax

I have following code

<!DOCTYPE html>
<title> Dashboard</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
jQuery(document).ready(function() {
url = "<?php echo $_GET['PATH_INFO']; ?>";
type: "POST",
url: 'http://localhost:8081/fetch_image',
dataType: "JSON",
data: {
external_source: url,

success: function(data) {
local_image= data[0]['local_source'];



I have no idea, how to show local_image on success of ajax Request

I need this in php so it will return content type jpeg header

Answer Source

in your success-function add:

$(body).append('<img src="' + local_image + '">');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download