There really isn't much difference to building a script that handles an AJAX request compared to a regular request. The main difference is that the AJAX request usually returns XML, or possibly just a small snippet of HTML.

The hard part around AJAX is the JavaScript side (since I am a perl developer, JavaScript is hard ;). There are already some JavaScript libraries out there that can really simplify this. I've used one called Sarissa that works pretty well, but I haven't done enough in this area to recommend the "best" JavaScript library out there. Just do some searching.

If you want an example using CGI::Application, then you can have a look at my attempt at building an Upload Meter (something like Apache::UploadMeter). It is just a prototype, so there isn't much in the way of documentation, but it does show how you can do AJAX with CGI::Application (as you will notice, it is no different from a regular CGI::Application module). Here is a tarball of the entire prototype.

I would like to wrap this up in a simple to use module at some point, but time is my enemy right now :)


In reply to Re: AJAX and Perl-based web applications by cees
in thread AJAX and Perl-based web applications by srdst13

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.