Let me go over this quickly:

>   var data = $.toJSON( ....# I convert JSON object to simple text
here you create a JSON encoded 'data' object, which is in line with
the following jQuery (Javascript) code:

>                         $.ajax({
>                                 type: 'POST',
>                                 url: '{{=URL(r=request,f='action')}}',
>                                 contentType: "application/json;
>                                 charset=utf-8",
>                                 data: data,
this means that you will be sending a JSON encoded 'data' in the
request body of a POST to your action (hence the need for sj.loads
(response.body.read()) on the server side). Side note: this is in
contrast to a GET method which encodes 'data' in a query string.

>                                 dataType: 'json'
this means you expect the response from the server to be in JSON

>                                 success:  function(data){ {{
this function is called when the ajax request finishes successfully
and 'data' will contain the response from the server (should be in
JSON as specified above, so somewhere in your action you have to make
sure it is).
Your success function has to manipulate 'data' using Javascript (not
Python) to obtain the info you need.

>                                                         import
> gluon.contrib.simplejson as sj
>                                                         data = sj.loads
> (response.body.read())
>                                                          value = data
> ["Name"][0]["key1"]
>                                                                    }}
>                                                   alert({{=value}}); }
>                                });
>                 });
>
>                 }

Hope this helps.
Denes.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to