[Javascript] Forward image via http with ajax

Terry Riegel riegel at clearimageonline.com
Fri Feb 2 16:18:14 CST 2007


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