[Javascript] Forward image via http with ajax

John Warner john at jwarner.com
Fri Feb 2 16:47:02 CST 2007


There is a web server on the other end of:
new Ajax.Request('http://clearimageonline.com/white.jpg'   isn't there?
I thought you were trying to avoid this or have I completely
misunderstood?

John Warner


> -----Original Message-----
> From: javascript-bounces at LaTech.edu 
> [mailto:javascript-bounces at LaTech.edu] On Behalf Of Terry Riegel
> Sent: Friday, February 02, 2007 5:18 PM
> To: [JavaScript List]
> Subject: Re: [Javascript] Forward image via http with ajax
> 
> 
> Here is my progress.
> 
> I can get Javascript to download an image, it looks like it ignores  
> the binary characters. For example I had a 1479 byte gif, after  
> downloading it its length was 1453.
> 
> Sooo, any ideas on how to get the image via XMLHttpRequest??
> 
> 
> Here is my code (I am using prototype.js to do some of the dirty work)
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// 
> www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html>
> <head>
> <title>Moveit</title>
> <meta http-equiv="pragma" content="no-cache">
> <meta http-equiv="cache-control" content="no-cache">
> <script language="javascript" type="text/javascript" src="http:// 
> clearimageonline.com/prototype.js"></script>
> <style>
>    <!--
>    BODY    {background: #888888;}
>    BODY,TD {font-size: 9pt; font-family: Verdana; font-weight:  
> normal; color: #000000}
>    A       {color: #2B4F9E; text-decoration: none}
>    A:Hover {color: #2B4Fff; text-decoration: underline}
>    -->
> </style>
> </head>
> <body>
> <center>
>    <a href="<<page>>">RELOAD</a><hr>1479 bytes
>    <script>
>     new Ajax.Request('http://clearimageonline.com/white.jpg',
>     {
>       method: 'get',
>       onComplete: function(image){alert('Received  
> '+image.responseXml.length+' bytes.'); }
>     } );
>    </script>
> </center>
> </body>
> </html>





More information about the Javascript mailing list