My First Ajax Script

I thought I would give this a try and it is pretty slick. The “My del.icio.us” section over on the right side is a full Ajax implementation. I used a CGI script on my server that goes and gets the details from “http://del.icio.us/rss/bobbalfe” and then gets processed by the JavaScript to put the list of linked titles into a specific section of the HTML DOM (id=mydelicious). The key here is the CGI Script on my server that retrieves the remote XML. You must do this since the XMLHttpRequest can not access XML from any server but the source of the page.

You can get a look at the script I wrote (mostly stole from samples) here.

The CGI is a Perl script on my server, here is the source. An obvious optimization when I have time would be to generalize this script and have it take in a parameter. This way I could use it for any remote feed.

#!/usr/bin/perl

use LWP::Simple;

print “Content-Type: text/xmlnn”;

my $content = get( “http://del.icio.us/rss/bobbalfe” ) or die $!;

print $content;

print “nn”;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.