[cgiapp] Ajax and JSON recipe

P Kishor punk.kish at gmail.com
Thu Apr 9 11:20:49 EDT 2009


On Thu, Apr 9, 2009 at 9:53 AM, Lyle Brooks <brooks at deseret.com> wrote:
> I have a need to incorporate Ajax calls with JSON data into
> our application.  I was looking for something in terms of a piece
> of "starter" code or a recipe.  I didn't see anything on the website
> related to it.
>
> CGI Application seems like such a robust framework, that this should be
> a natural fit.
>
> Does anyone have a short starter example of code (both server and client)
> that they would be willing to post/share that would show Ajax/JSON
> usage with CGI::Application?

Short advice... don't. That is, don't mix CGI::App in the backend with
Ajax in the front-end. Keep separate things separate.

Create your JSON stream (I query the db, and convert the result set
into JSON using JSON.pm) and send it back to the client via
HTML::Template (I have a simple, one variable template with <TMPL VAR
JSON_DB_QUERY> or something like that).

Use your favorite way of manipulating the data on the client (I use
jQuery to initiate the Ajax call and to deal with the results).


>
> Thanks much.
>
> Lyle Brooks
>
> #####  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/                 ##
> ##                                                            ##
> ################################################################
>
>



-- 
Puneet Kishor http://www.punkish.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Carbon Model http://carbonmodel.org/
Open Source Geospatial Foundation http://www.osgeo.org/


More information about the cgiapp mailing list