CGI-Ajax reviews

RSS | Module Info

CGI-Ajax (0.707) *****

Wonderful module!
I use mod_rewrite on my projects and I can't use CGI::Ajax directly embedded on my pages because there is a conflict with script name (URL is located at /bla-bla/bla but real script works at /cgi-bin/bla/ But I use it in separate *.js files where I copying JS producing CGI::Ajax (CGI::Ajax uses /bla/ and I replace it with /bla-bla/bla in bla.js file manualy).

Thank you, guys for great your work!

CGI-Ajax (0.701) *****

There are a number of contradictory reviews regarding this module, here is my own.

I have a lot of dynamic pages on my corporate LAN produced with good ol' There is no performance issue, insofar as they are a run with a frequency that is measured in hits per day, rather than hits per second. A number of the programs are over five years old and these days present a lot more information, which makes the click/submit/refresh cycle cumbersome for the end user. The main problem being that after clicking on submit at the end of the page, the refreshed pages doesn't reset itself to the last field updated/modified.

Thus I cast around for an easy way to "AJAXify" the pages, to retrofit some user friendliness and allow updates to be made leaving the page at the same position. I had a quick scan an CPAN, skimmed the documentation of this module, and figured it would do the job. So I downloaded it, and after an hour of futzing around (which would have taken 10 minutes had I read the documentation more carefully), I had my asynchronous updates up and running.

I have therefore been able to earn my old programs a reprieve. They can continue to do their job and I can put off having to rewrite them using a clean MVC template-based approach. Which would be fun, but not really justified since they aren't really broken. If you find yourself in a similar situation, this module is ideal.

CGI-Ajax (0.701) **

This module is nice for quick and dirty stuff if you’d prefer not to learn anything about Javascript. It’s not very suitable for serious use, though.

It builds a bunch of Javascript for inclusion in your HTML, so you won’t benefit from caching. The documentation encourages the use of onClick attributes in the markup, rather than unobtrusive scripting. It turns Ajax into RPC that won’t easily play well with frameworks and disregards the fact that there’s HTTP in the middle (you can’t use methods other than GET and POST or set any headers, eg. use conditional requests). The code is tightly coupled with (which, admittedly, is a benefit in quick’n’dirty scenarios).

In short, CGI::Ajax gives you the worst in webapps as of 2006 combined with the worst in webapps as of 1996.[1]

If you are serious and need to build more than a tinkertoy of an Ajax app (which, admittedly, not all of us need to), I would suggest to instead acquaint yourself with the following things:

a) the meaning of “unobtrusive Javascript” (see Wikipedia for a very short overview)
b) jQuery (a Javascript library, see
c) ETags and conditional requests (beyond just their use for caching)

That will give you the tools necessary to build Ajax apps that scale up nicely – with code size, in maintainability; and with your audience, in performance.

Of course, that won’t scale *down* as nicely. If you just want to slap together a page with a few buttons to change state on the server (you’re doing home automation and have put your coffee maker on an X10 wire, say), then CGI::Ajax will allow you to get that done with the minimum effort possible.


[1] Exaggerated for pithiness, I’ll admit. It could certainly be much worse than it is. :)

CGI-Ajax (0.701) *****

I use CGI::Ajax with CGI::Application and have found it to be extremely useful, especially since in most instances it frees up developers from having to write any javascript at all. It also comes with plenty of examples in the “script” directory which illustrate solutions to typical real-world problems.

I guess my only reservation is that the generated javascript will appear in your HTML head tags. The javascript consists of two parts, standard CGI::Ajax output which will always be the same, and context-specific javascript which will link js functions to your perl subroutines. I’d like to have a flag in CGI::Ajax that allows you avoid outputing the standard js, as it can always be included in a separate .js file. Secondly, I’d like a method to just output the context-specific javascript, so that it too can be saved to a file. That way, the only things that need to be in your head tags are the references to the .js files.

If you wish to return multiple values from an external script (which is how I use CGI::Ajax), you need to return the results as a string, using the text ‘__pjx__’ as a delimiter between each value. This is documented, but is not given much prominence, so it’s easy to miss.

But the fact remains that this module enables you to write rich Ajax apps pretty quickly. Congrats to the authors

CGI-Ajax (0.697) ***

I want to like CGI-Ajax, but it is hard to use. It does not have the "functional" interface available to it that has which makes it hard to integrate into legacy code. It stuffs a whole bunch of JavaScript into the header of the output page. It also has very limited examples as well as no proper mailing list. The documentation is out of date and not centralized, for example on CPAN it tells you to go to the web site, on the web site it tells you to go to Google groups. Even there at Google groups there is a limited number of people there who are using the module.

This can be a great module, it could be really useful. It needs more careful documentation and a more flexible interface.

CGI-Ajax (0.692) *****

CGI::Ajax is an excellent module for implementing Ajax stuff quickly. I had a Ajax-enabled page up and running in 10 minutes. The interface is easy to use and the module works very well.

Keep up the good work!

CGI-Ajax (0.641) ****

This is a nice module with (almost) adequate documentation. However, its usage was hampered by some hidden bugs (as of V0.6) and slight interface deficiencies.

The main advantage the module provides is to encapsulate the routine AJAX code into easy-to-use functions such that you only have to worry about your script's own logic (and not AJAX details), what input your script needs and where (which html elements) on the web page to place the output. The packaged example scripts are in some cases much better than the documentation, which has some errors (like the first script in the synopsis wouldn't even produce anything 'cause it missed the 'print' in 'print $pjx->build_html( $cgi, \&Show_HTML);').

Another good thing I found out was that one could easily make the script deal with both AJAX request and traditional POST/GET requests. It came in handy for one of my web apps (since it needs to stream an Excel file in some situations).

Now the bad part: V0.6 has a hidden bug that took me longer to debug than I could've worked out an AJAX web app myself as AJAX is easy in itself. I emailed the authors of the bug (and its cousins) and hopefully it'd be soon patched. (Edit: author fixed the bug in V0.64)

Another thing is that the module does not deal with multiple select well at all. In fact, all selections are flattened into 1D array such that if you have multiple html elements, you don't know where the first selection starts (or the last ends) in the array you got in your perl_func. But it's also easily patchable and I emailed an suggestion to author. (Edit: fixed in V0.641)

All in all, this is a nice module that'll save your time when you build AJAX app many times. If it fixes its current issues, it'd be great.

CGI-Ajax (0.43)

Love it. Using it extensively with FormBuilder and Template Toolkit, and the prototype / libraries combination for DOM related eye candy.

With FormBuilder, simply set your jsfunc option to a scalar containing the javascript function you want called. Which, in this case, the the same function you are registering with your CGI::Ajax object. Such as:


my $cgi = CGI->new();
$foo = "get_items(['my_value_div_id'],'returndiv')";
my $form = CGI::FormBuilder->new( #blahblah

jsfunc => $foo;

... );
sub retrieve_items {

my $item_num = shift;

my $page = "";

$page .= %items{$item_num};

# whatever, call your database, make a

# template, render a form, whatever

# just append all output to $page

return $page;

sub show_html {

my $page = "";

$page .= $cgi->header;

# blah blah do whatever,

# call you exported function

# just append it all to page

return $page;
my $pjx = CGI::Ajax->new('get_items', \&retrieve_items);
print $pjx->build_html($cgi, \&show_html);


The documentation improvements could include updating Changes files.

CGI-Ajax (0.31) *****

CGI-Ajax has very good browser support, which I consider to be of paramount importance. I've tried the example script with Firefox, Safari, Konqueror, IE 6.0, and Opera 8 and it works flawlessly.
2 hidden unhelpful reviews