Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > ajax image data fetch, javascript IMG data update?

Reply
Thread Tools

ajax image data fetch, javascript IMG data update?

 
 
Marcus
Guest
Posts: n/a
 
      12-08-2006
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?

 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      12-08-2006
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.

 
Reply With Quote
 
 
 
 
Peter Michaux
Guest
Posts: n/a
 
      12-08-2006

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
putting img above/bellow img ? Jopek HTML 7 04-26-2009 10:26 PM
how to replace this like <img width=100 ...> with <img width="100" ...> zhanye815@gmail.com Perl Misc 7 06-21-2006 11:16 PM
Problem: <img></img> Philipp Lenssen XML 15 07-03-2005 09:23 AM
how to download img from html img tag news.austin.rr.com ASP .Net 2 04-27-2005 06:25 PM
Inserting an <img src="X"> into the DOM with javascript under IE ignores image cache Todd Javascript 0 07-24-2003 02:03 AM



Advertisments