469,889 Members | 1,382 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,889 developers. It's quick & easy.

ajax image data fetch, javascript IMG data update?

Here is a toy problem describing what I want to do:

I have a web page with a single IMG element (say for a 128 x 128
"screen") which is initially blank (image=black pixels). I have AJAX
code that polls my server for updated image data. I would like to use
AJAX to fetch the image data, and then use javascript to update the IMG
data to show the new picture. This needs to work in IE and Firefox.

I've seen a few similar posts, but no concrete answers: is this
possible? If so, how?

Dec 8 '06 #1
2 5408
Marcus wrote:
Here is a toy problem describing what I want to do:

I have a web page with a single IMG element (say for a 128 x 128
"screen") which is initially blank (image=black pixels). I have AJAX
code that polls my server for updated image data. I would like to use
AJAX to fetch the image data, and then use javascript to update the IMG
data to show the new picture. This needs to work in IE and Firefox.

I've seen a few similar posts, but no concrete answers: is this
possible? If so, how?
It is not possible to provide an IMG element with binary data through
an XML HTTP request.

If it was possible to use a javascript pseudo-protocol URL as the SRC
of an image it may have been possible, but tortuously difficult (issues
with the text response being binary data (originally) interpreted as
UTF-8 into a javascript string of 16 bit code points and then needing
to be translated into a string that can be interpreted by the IMG's SRC
(on Mozilla/Gecko, where this is possible, the sting used is expected
to have a single byte of data in the each character)).

Richard.

Dec 8 '06 #2

Marcus wrote:
Here is a toy problem describing what I want to do:

I have a web page with a single IMG element (say for a 128 x 128
"screen") which is initially blank (image=black pixels). I have AJAX
code that polls my server for updated image data. I would like to use
AJAX to fetch the image data, and then use javascript to update the IMG
data to show the new picture. This needs to work in IE and Firefox.

I've seen a few similar posts, but no concrete answers: is this
possible? If so, how?
You can use Ajax to poll the server to determine when the image is
ready or what the new URL will be. When the new picture is available
just change the src attribute of the image tag and the browser will
automatically get and update the image.

Peter

Dec 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Randell D. | last post: by
10 posts views Thread by G Matthew J | last post: by
5 posts views Thread by darrel | last post: by
35 posts views Thread by Kaante | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.