[cgiapp] CA and AJAX

Ben Hitz hitz at genome.stanford.edu
Tue Jan 29 11:27:45 EST 2008


I have been starting to interface my CA  with both DBIx::Class and  
the Rico js library (www.openrico.org), which is derived from  
prototype.js.

Generally, I haven't found much use to actually write javascript from  
perl; I prefer to use Templates for the javascript and XML and use  
the perl to define variables and configure.  There is an  
HTML::Prototype library and associated CGI:App plugin.  At one point  
I was looking at jQuery and had to write a 6 line  
Cgi::App::Plugin::jQuery  module (but I never used it).

One thing that tripped me up for a day or two was forgetting to  
escape $ in TT2 so that it appears as $(variable) in javascript.

Ben


On Jan 29, 2008, at 6:29 AM, Michael Peters wrote:

> Robert Hicks wrote:
>> I am looking at the Ext Js 2.0 AJAX framework and it looks really  
>> good
>> (I also like jQuery). Is anybody working on an easy way to call Ext
>> stuff from Perl through CA?
>
> Ajax stuff is fun to do, but it's really no different from normal  
> web work, at
> least from a C::A perspective. You call run modes just the same. It  
> doesn't
> matter how the request makes it to the backend. The only real  
> differences are
> the following:
>
> + you almost never return full pages (header, nav, footer, etc).  
> This is pretty
> easy to do with templating. I just set a no_wrapper param that goes  
> to my
> templates on Ajax requests to turn off the extra stuff I don't need.
>
> + JSON - If I have any advice about Ajax programming is don't use  
> XML if you can
> avoid it. It's nice to be able to read RSS feeds from some other  
> source, but if
> you can control the data source use JSON. It's faster, smaller,  
> easier to read
> and more "natural" to Perl. Check out C::A::Plugin::JSON for some  
> easy ways to
> use it
>
> -- 
> Michael Peters
> Developer
> Plus Three, LP
>
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################

--
Ben Hitz
Senior Scientific Programmer ** Saccharomyces Genome Database ** GO  
Consortium
Stanford University ** hitz at genome.stanford.edu





More information about the cgiapp mailing list