On Jan 9, 2008 9:51 AM, Ben Hoyt <[EMAIL PROTECTED]> wrote:
>
>
> > I hope web.py can provide us AJAX func.
> >
>
>  It sure can. :-)  An AJAX request is just a normal request, but initiated
> via JavaScript and returning XML or JSON. For example, a web.py handler that
> grabs the number of users on your site and returns it as JSON (untested):
>
> class num_users:
>     def GET(self):
>         n = web.select('users', what='count(*) as n')[0].n
>         web.header('Content-Type', 'text/plain')
>         print '[%d]' % n

JSON has its own mime type:

application/json

http://www.ietf.org/rfc/rfc4627.txt

It's always a good thing to use it.

And please don't add all the AJAX helpers � la Ruby On Rails into
web.py, no one needs that. (If it was the initial question)

-- Yoan

> DecentURL.com uses an AJAX-style request like this for its live "grabbing
> title" feature. See the docs for api-title here:
>     http://decenturl.com/tools#api-title
>
> And here's the AJAX JavaScript that calls this:
>     http://static.decenturl.com/common.js
>
> -Ben
>
>
> --
> Ben Hoyt, http://benhoyt.com/
>  >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to