Hey Tim -- 

> Say, has anyone got a minimal example of embedding AJAX into 
> a CGI::APP,
> preferably using some library to abstract the Javascript (CGI::Ajax or
> SAJAX or something else) ?

I'm sure a few other people will email you examples of AJAX
implementations.  I just wanted to make one point:  CGI-App's "run
modes" construct is perfect for AJAX applications.  

AJAX is, essentially, a single web page which has functions within it
which require server side integration.  Put most simply:  Web functions
*WITHOUT* their own web page.  This is the exact opposite of a "server
page" system (Mason, EmbPerl, ASP, JSP, PHP, etcetera).  This is,
however, exactly the purpose of CGI::Application.  Functions without
pages.

Consider a function to do auto-completion of a form field in-page.  One
example might be product IDs -- the user types in the first couple
letters, and possible completions appear as drop-down options.  This
would easily be implemented as a run-mode:

  sub propose_products {
    my $self = shift;
    my $q = $self->query();
    my $prefix = $q->param('product_name');
    my @candidates = $self->get_products_starting($prefix);
    return join("\n", @candidates);
  }

Your Javascript would make an HTTP request on timeout (for example, when
the user stops typing for a couple seconds).  That request would be
internal, and would get back a line-delimited list of options, which
would then be displayed via DHTML.

Through this structure, it is easy to see how CGI::Application's
inherent philosophy is eminently compatibly with AJAX.  (In fact, it's
almost like it was made for it!)

TTYL,

-Jesse-


--
 
Jesse Erlbaum
The Erlbaum Group
[EMAIL PROTECTED]
Phone: 212-684-6161
Fax: 212-684-6226
 

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to