Trying to Display Image in an iFrame

  • Thread starter Abhishek Srivastava
  • Start date
A

Abhishek Srivastava

Hello All,

I am trying to obtain an image asynchronously for this I have written code
which uses XMLHTTP object to retreive the image.

now I have to display this image in an iframe. when I say

iframe.contentWindow.document.write(xmlHttp.responseText);

I get an text as "JFIF" in my frame.

Why am I not able to see the image ?

I cannot do something like <img src="img.aspx" /> because I want to fetch
the image asynchronously. using the img tag would mean that I fetch the
image in the same thread as the main page.

regards,
Abhishek.
 
H

Hans Kesting

Hello All,
I am trying to obtain an image asynchronously for this I have written code
which uses XMLHTTP object to retreive the image.

now I have to display this image in an iframe. when I say

iframe.contentWindow.document.write(xmlHttp.responseText);

I get an text as "JFIF" in my frame.

Why am I not able to see the image ?

I cannot do something like <img src="img.aspx" /> because I want to fetch the
image asynchronously. using the img tag would mean that I fetch the image in
the same thread as the main page.

regards,
Abhishek.

Are you sure? IIRC first the browser needs to decode the html to find
the <img> tag. The browser will then issue a seperate request to fetch
that image.
And an image is not "text", so that may be why "responseText" gives
wrong results.

Hans Kesting
 
A

Abhishek Srivastava

The browser will then issue a seperate request to fetch that image.

It is a separate request. But it is on the same thread. In my application,
first the browser submits the request for form processing when that
completes, it is downloading the image.
And an image is not "text", so that may be why "responseText" gives

So how can I extract the binary data out of HTTPRequest. Sorry but I am not
very well versed with JavaScript programming.

regards,
Abhishek.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top