First of all thanks so much for your help, Leonel. I finally got it.
I had a concept mistake. I had to declare a variable to get the data of the
client wiht the same structure of the data. I used datos =
str(request.vars), it is correct because I can retrieve data: {'key':'value
','key2':'value2'} as a string, but it is not the proper way. The proper
way is
datos = str(request.vars.key),str(request.vars.key2)]
So I can get the values at the client with
data.datos[0], data.datos[1]
That is solved. The second issue I had was tha I wanted to send the values
to the controller, to store them in a database. I finally use the jquery
set val () and send it through a form field.
$("#test").val(data.datos[0])
That's it.
El miércoles, 17 de diciembre de 2014 13:30:03 UTC+1, Leonel Câmara
escribió:
>
> What do I mean what do I suggest I see nothing wrong with it.
>
> Do you want to change the HTML after getting the response? If it's that
> you can do something like this:
>
> {{extend 'layout.html'}}
> <h2>Template default/test2.html</h2>
>
>
> <dl>
> <dt>Key</dt>
> <dd id="key"></dd>
> <dt>Key2</dt>
> <dd id="key2"></dd>
> </dl>
>
> <script>
> $(document).ready(function(){
> $.ajax({
> type: 'POST',
> url:'http://127.0.0.1:8000/MFREG/default/test2.json',
> contentType: "application/json; charset=utf-8",
> data: {'key':'value','key2':'value2'},
> dataType: 'json',
> success: function(data){
> for (var key in data) {
> $('#' + key).text = data[key];
> }
> }
> });
> });
> </script>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.