Good Afternoon,

If you haven't heard of XMLHTTPReqeust aka Remote Scripting aka AJAX it's 
basically a way for web pages to communicate with the server and return 
information through JavaScript without having to refresh the page.

You can read more about it here: 
http://www.adaptivepath.com/publications/essays/archives/000385.php and see it 
in action here: http://www.google.com/webhp?hl=en&complete=1

There are currently some useful applications for AJAX and, I'm sure, lots of 
superfluous ones too. I'm hopeful that the number of useful ones will grow as 
the technology becomes more wide-spread and easy to use, which brings me to the 
point of my post.

I stumbled across a site called SAJAX (http://www.modernmethod.com/sajax/) 
today that has developed a *S*imple AJAX method that can be used with Perl, via 
their Sajax.pm file.

After playing around with it for a while, I was able to strip down their code 
(actually getting rid of all their Perl code, and leaving only the JavaScript, 
which I edited and packaged up as a .js file) in-order to figure out exactly 
how AJAX works and more importantly, how to easily integrate it with a CGI::App 
based module.pm file.

I converted their demo app -> 
http://www.modernmethod.com/sajax/sajax-0.8/php/example_multiply.php to one 
running on my code using C::A -> http://www.unobserved.org/misc/rs/

I invite anyone that's interested in learning more about using AJAX to take a 
look at my sample app.

I've provided source files for download from the page which include:
 - index.html
 - remotescript.js ( the required javascript library that does all the 
XMLHTTPRequest magic )
 - rscalc.cgi ( C::A instance script )
 - RemoteScriptCalc.pm ( C::A Application Module )

The example uses 2 very simple run-modes, a multiply and a divide run-mode. The 
divide() run-mode takes advantage of how to handle error messages when 
communicating with the script remotely.

As far as I can tell, I see no problem with including a couple of AJAX based 
run-modes into an existing C::A module (provided you setup the JavaScript on 
the calling page properly).

Hopefully, some others will find this useful and hopefully be able to use it in 
their C::A apps. I know I intend to implement it soon for apps where I know the 
browser requirements are met.

I didn't document the code very much, but I kept it nice, clean and organized 
to help readability. Good knowledge of javascript is needed to hack the 
remotescript.js file, but you don't need to be an expert in-order to use it.

If you want to talk about the applications of using XMLHTTPRequest with C::A 
I'm sure we can keep this on the list, but if you're having trouble getting my 
sample code to install or work on your server contact me directly so we don't 
clutter up the list. I'll try and help out time permitting.

BTW - I don't know what the exact browser requirements are however, I just know 
it works on my WinXP IE6 or Firefox. The SAJAX site might have more info on 
that.

That URL again is: http://www.unobserved.org/misc/rs/
Steve Comrie
LEAD SOFTWARE ARCHITECT | OCTANE


T: 416.977.2525
F: 416.977.8481

355 ADELAIDE ST. W. SUITE 1B
TORONTO, ONTARIO  M5V 1S2

WWW.OCTANE.TO 

Reply via email to