On Mon, Jan 25, 2010 at 09:31:11AM +0530, Anand Chitipothu wrote: > On Sun, Jan 24, 2010 at 8:15 PM, Indrajith <[email protected]> wrote: [snip] > > requirements, and AJAX is the way forward. I am not able to find good > > links which talks on people experiences using web.py and AJAX. Can > > anybody who has already used these together share the positives and > > negatives ? > > AJAX is no different from a regular request. Just that is it sent > without refreshing the page at the client side.
True. Let me show you how I'm handling AJAX request at the moment. Right now, I have a class called ``pieces`` [1] which is associated to the url ``/pieces`` in the urls tuple. Inside this class, I have a number of classmethods which return pieces of HTML that are requested by the Javascript code. How does the Javascript code indicate which function it wants? Well, the ``pieces`` class has a GET() method which allows the Javascript code to do GET ``/pieces?func=<fname>&<1st-arg-name>=<1st-value>&<2nd-arg-name>=<2nd-value>...`` to get the return value of a call to ``<fname>(<1st-arg-name>=<1st-value>,<2nd-arg-name>=<2nd-value>, ...)`` Of course, <fname> has to be in some list of exported functions for this to work. I don't know if this is the cleanest way to do this (it pretty likely isn't) but just wanted to share it. Thanks, [1] http://github.com/crazy2k/pfweb/blob/2b2ee3ff7182058ee11d86399e5f3886124b4861/pages.py#L53 -- Pablo Antonio (AKA crazy2k) http://www.pablo-a.com.ar/ -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
