By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,480 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,480 IT Pros & Developers. It's quick & easy.

ajax image data fetch, javascript IMG data update?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a

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.