One of the great things about web.py is that doesn't matter if you're
showing an HTML page, an RSS feed or JSON data; you just print it (or
'return it' in the dev version).

How do you return a JSON string? The easiest way is using the
"simplejson" Python library.
You can't/must not return all the strings, so you do something like
this:

import web
import simplejson

urls = { '/somepage/(\d)+' , 'somepage'}

class somepage:
    def GET(self, pagenum):
        STRINGS_PAGE = 100

        dbstr = web.select('stringtable', what='text'
                limit = STRINGS_PAGE,
                offset = STRINGS_PAGE*pagenum)
        strs = []
        for s in dbstrs:
            strs.append(s.text)

        result = simplejson.dumps(strs)
        print result


And call "/somepage?pagenum=X" usign JQuery's AJAX functions.



On 24 mar, 18:09, dineshv <[EMAIL PROTECTED]> wrote:
> Hi!  I want JavaScript/JQuery code to access an array of string data
> (10,000's of strings) from the webpy/Python server using JSON.  In
> time, we'll want the JS/JQ code to access a database (initially
> SQLite).  Is there any example code of how the JS/JQ accesses the
> array of strings using JSON?
>
> Dinesh
--~--~---------~--~----~------------~-------~--~----~
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