Having problem to get GIF file through XMLHttpRequest



hi dear committee here,
Recently I am trying to writing a widget with will request a gif file
from the server. I have done most of the work and the server now is
sending back the gif file with the following header:

Server: Microsoft-IIS/5.0 Cache-Control: private Date: Fri, 23 Sep 2005
13:16:29 GMT Content-Length: 154 Content-Type: image/gif Via: 1.1
zproxy (NetCache NetApp/5.5R3D2)

However, when I use the code below to set the image to correscponding
element, it just doesn't show:
//code to set gif to image element
document.getElementById("spamcode").src = req.responseText;

I have tried to view the responseText in a div area using the
following code:
//show content of sent back gif file
document.getElementById("indicator").innerHTML = req. responseText();

and it simply give me a string like this:
GIF89a ñÿÿÿÿÿÿ!ù,
k"(¢D?%JQ¢D?J(¢D?B"Q"D?J(P¢@?%B"Q"D?!J,,(P¢@?J(Q
D?! P"D?J(Q¢@?% "Q"D?!JP¢D?U;

I am quite new to javascript and just get my hand on the
XMLHttpRequest. Tried a lot of method like:
document.getElementById("spamcode").src =
"data:image/gif,base64;"+req.responseText;
But still, I am no lucky.

I am not sure whether it is because of the decoding problem because I
searched the web and the GIF89a file content always shows like
GIF89a\1\0\1\0\200[...]\1\0;

Hope you exports could give me some way to solve this problem,
anyway, school final exam is coming..

regards,
Liao Liang
Nanyang Technological University

.



Relevant Pages

  • Re: how to save an edited image ( painted on an applet) as .jpg or .gif
    ... edited image as a .jpg or .gif file. ... applet will either need to be signed and trusted, ... the server, ... redirect the images back to the client). ...
    (comp.lang.java.programmer)
  • Re: Unable to Display Local GIF
    ... If you have these registry keys, export them then delete ... >> If you drag and drop the GIF file into an IE window, ... >>> upload to a server. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Error Message help
    ... Server Error: The folder that would hold URL `pages/port ... Having been told by some proffessional web designer that ... message the bit with port wynnstay in has been changed to port_wynnstay. ... publish that gif file from my local coy to the server and it can't, ...
    (microsoft.public.frontpage.client)
  • Re: pure asp way to get image width and height
    ... we have aspJPEG on the server, ... > methods to fetch image width and height with that, ... A gif file starts with 6 bytes of header containing something like ...
    (microsoft.public.inetserver.asp.general)