All pastes #498363 Raw Edit

ajax example

public text v1 · immutable
·published 2007-05-20 10:45 UTC
rendered paste body
---- HTML Page ----
<html>
<head>
<script src="prototype.js"></script>
<script src="json.js"></script>
</head>
<body>
<div id="images"></div>
<script>
var pars = 'cmd=checkImages';
var myAjax = new Ajax.Request(
   url, 
   {
      method: 'get', 
      parameters: pars, 
      onComplete: drawImages
   });

function drawImages(response) {
   var images = $A(reponse.parseJSON());
   images.each(function(image) {
      $('images').innerHTML =+ "<img src=\"" + image +".jpg\">";
   });
}
</script>
</body>
</html>


---- perl code ---
#!/usr/bin/perl
 
use CGI;

use JSON;
use strict;

my $out;
for(my $i=0;i<=8;i++) {
   push @$out, $i if -e "6/$i.jpg";
}
print "Content-type: text/html\n\n";
print objToJSON($out);