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.

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
$('.imageTag').attr('src',image);

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';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.