[web2py] Re: json empty with jquery

2014-12-16 Thread Leonel Câmara
What do you mean it's empt? It's an object. Try and change your alert to alert("Data: "+ data.datos); -- 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) --- Yo

[web2py] Re: json empty with jquery

2014-12-16 Thread Jacinto Parga
I mean, I try to send data: {'key':'value','key2':'value2'} so I expect to get {'key':'value','key2':'value2'} in the controller. I've tried your suggestion and that's the result:

[web2py] Re: json empty with jquery

2014-12-16 Thread Leonel Câmara
Well it's supposed to be empty. You're calling the controller like this: http://127.0.0.1:8000/MFREG/default/test2.json This URL has neither args nor vars. Then you do this: datos = str(request.vars) datos2= request.args(0) request.vars is an empty Storage so when you convert it to str

[web2py] Re: json empty with jquery

2014-12-16 Thread Jacinto Parga
Ok, I.m getting closer. So I change my url call, like this url:'{{=URL('default','test2.json',args='data.datos')}}', but I still have an empty reques.vars. How should I call the controller to pass the data field as a json from the view scritp to the controller? What I am looking for is to send

[web2py] Re: json empty with jquery

2014-12-16 Thread Leonel Câmara
Humm request.vars shouldn't be empty because you're sending them in data. Add a print request.vars to the controller and see what's there. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py

[web2py] Re: json empty with jquery

2014-12-16 Thread Jacinto Parga
I did with {{=BEAUTIFY(response._vars)}} and the result is: datos: So request.vars is empty. If I change the post method for a get method, I can see the correct result at the alert window, but not in the controller, I mean it works in the client side: Wiht get method:

[web2py] Re: json empty with jquery

2014-12-16 Thread Leonel Câmara
Well {{=BEAUTIFY(response._vars)}} Won't see anything because the vars are only there in the ajax request. That's why it works in your alert. It should work with POST too. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code)

[web2py] Re: json empty with jquery

2014-12-16 Thread Jacinto Parga
Yes, it should. I don't know why not. Maybe I'll try with jquery... El martes, 16 de diciembre de 2014 18:59:18 UTC+1, Leonel Câmara escribió: > > Well > > {{=BEAUTIFY(response._vars)}} > > Won't see anything because the vars are only there in the ajax request. > That's why it works in your alert

[web2py] Re: json empty with jquery

2014-12-16 Thread Leonel Câmara
You're already using jquery. I think the problem is that you're specifying the contenttype. Remove that line and let it use formencode. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/is

[web2py] Re: json empty with jquery

2014-12-16 Thread Jacinto Parga
YES!!! Finally. Thanks so much. The only thing now is how to handle the string in the controller. I guess it should be stored in reques.post_vars El martes, 16 de diciembre de 2014 19:36:04 UTC+1, Leonel Câmara escribió: > > You're already using jquery. I think the problem is that you're specif

[web2py] Re: json empty with jquery

2014-12-16 Thread Leonel Câmara
It should, but it should also be in request.vars which is the standard place to deal with it, you should have request.vars.key and request.vars.key2. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.

[web2py] Re: json empty with jquery

2014-12-17 Thread Jacinto Parga
Sorry, but they are not stored in request.vars as expected. It works fine in the alert window, but I can't retrieve the values in the controller to handle them. I have tried with a diferent function in the controler, like this: def test2(): result=testpost() return locals() def tes

[web2py] Re: json empty with jquery

2014-12-17 Thread Leonel Câmara
Jacinto they are in request.vars otherwise you wouldn't see them in the alert window. Let's walk through what is going on here: 1. You open the address in the browser http://127.0.0.1:8000/MFREG/test2 as the extension is omitted web2py assumes HTML and your HTML view is processed 2. That URL doe

[web2py] Re: json empty with jquery

2014-12-17 Thread Jacinto Parga
Yes, so what do you suggest?. Do I have to fill my request.vars before the document is loaded? How can I do it? El miércoles, 17 de diciembre de 2014 12:43:30 UTC+1, Leonel Câmara escribió: > > Jacinto they are in request.vars otherwise you wouldn't see them in the > alert window. Let's walk

[web2py] Re: json empty with jquery

2014-12-17 Thread Leonel Câmara
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'}} Template default/test2.html Key Key2 $(document).ready(function(){ $.ajax({ type:

[web2py] Re: json empty with jquery

2014-12-23 Thread Jacinto Parga
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':'value