CGI::Ajax is an object-oriented module that provides a unique mechanism for using perl code asynchronously from javascript-enhanced web pages. You would commonly use CGI::Ajax in AJAX/DHTML-based web applica- tions. CGI::Ajax unburdens the user from having to write any javascript, except for having to associate an exported method with a document-defined event (such as onClick, onKeyUp, etc). Only in the more advanced implementations of a exported perl method would a user need to write any javascript. CGI::Ajax supports methods that return single results, or multiple results to the web page, and the after version 0.20, supports returning values to multiple DIV elements on the HTML page. Using CGI::Ajax, the URL for the HTTP GET request is automatically generated based on HTML layout and events, and the page is then dynamically updated. We also have support for mapping URL's to a CGI::Ajax function name, so you can separate your code processing over multiple scripts. Other than using the Class::Accessor module to generate CGI::Ajax' accessor methods, CGI::Ajax is com- pletely self-contained - it does not require you to install a larger package or a full Content Management System, etc. A primary goal of CGI::Ajax is to keep the module streamlined and maximally flexible. We are trying to keep the generated javascript code to a minimum, but still provide users with a variety of methods for deploying CGI::Ajax. And VERY little user javascript.
coderef example | This shows an example of perl functions declared using code refs |
subroutine example | Same example but using subroutines, not code refs |
many returns | Same example but with many return values coming from the perl function, each going to a different div |
regular expressions | Another example using regular expressions in a real-time matching display |
example from POD docs | The example from the documentation in the module |
dynamic select boxes | This example shows how to dynamically change select boxes, based on other select box selections |
chained CGI::Ajax Functions | An example of multiple exported perl functions chained to a single event (req CGI::Ajax >=0.56!) |
Radio button example | An example showing off the update CGI::Ajax that handles radio buttons (req CGI::Ajax >=0.58!) |
Outside URL example | An example of using CGI::Ajax and exporting a function to javascript that refers to an outside URL for processing |
Callback example | An example showing a javascript function calling a CGI::Ajax exported function |