Jesse Erlbaum wrote:
> 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.

Maybe just a point of style, but you can also use JSON to simply send a
JavaScript array back to the client so that the JavaScript wouldn't even
have to mess will splitting up lines or rearranging the data.

> 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!)

I completely agree. I wonder how hard this AJAX transition will be for
frameworks that rely on page-style sites.

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              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