By the following code i got image as the responce.

if (http.readyState == 4 && http.status == 200) {
      ver image=http.responseText;

actually when i gave a call to server using ajax the server responded with an image. so now i have stored the image in a variable "image". I think this is fine but now how do i save the binarydata in variable "image" as an image file or how do i display it in a browser? can we get the binarydata using ajax? if so how do i save or display it in browser? kindly help me? Thanks in advance.

3 Years
Discussion Span
Last Post by yaragalla_mural

even the following code from te above post is also giving error

ver image=http.responseText;

How to deal with binary data in ajax?


you can display the image in the following way

<img src="" class="imageTag">

//your script

This will show the image in the browser,Hope it helps


What you need to do is have the server return a link to the image. Something like "http://mysite.com/images/my_image.jpeg". Then take that link and apply it to the "src" tag of an image element. designershiv's answer above would do it if you were using jQuery but it doesn't look like you are. To apply the source do this:

var imageElem = document.getElementById('image_elem_id');
imageElem.src = 'http://mysite.com/images/my_image.jpeg';

Edited by hag++

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.