jgfoot:
I just tried to make your example code work but it doesn't display the
html. Are there some lines missing?
Dinesh
On Mar 24, 6:52 pm, jgfoot <[EMAIL PROTECTED]> wrote:
> Ah, jQuery and web.py are great together.
>
> Try this:
>
> ###################################
> ./river.py:
> ###################################
>
> import web
>
> # A sample "database" using just a Python dictionary object
> database = {
> "Tokyo" : "Sumida",
> "Paris" : "Seine",
> "Minneapolis" : "Mississippi",
> "Manaus" : "Amazon",
> "Cairo" : "Nile",
> "Beijing" : "Yangtze",
> "Seoul" : "Han" }
>
> class river:
> def GET(self, cityName):
> response = database.get(cityName, "I don't know")
> print repr(response), # a poor man's JSON converter
>
> web.run( ('/river/(.*)', 'river') , globals())
>
> ############################
> /static/index.html:
> ############################
>
> <html>
> <head>
> <title>City to river</title>
> <script src="/static/jquery-1.2.3.js"></script>
> <script type="text/javascript">
>
> function lookupRiver() {
> var whatTheUserEntered = $("#cityName").val();
> $.getJSON("/river/" + whatTheUserEntered, function(data){
> $("#riverName").html(data);
> });
>
> }
>
> $(document).ready(function(){
> $("#doLookup").click(lookupRiver);
>
> });
>
> </script>
> </head>
> <body>
> <p>Enter the name of a city:</p>
> <input id="cityName" />
> <input type="submit" value="Go" id="doLookup" />
> <p id="riverName"></p>
> </body>
> </html>
>
> ##############################################
>
> Make sure jquery-1.2.3.js is in /static also.
>
> Then, python river.py, go tohttp://localhost:8080/static, and enjoy.
>
> On Mar 24, 7:09 pm, 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
-~----------~----~----~----~------~----~------~--~---