Clara I'd suggest to use the full json service support of web2py, makes everything easier
do the following: make sure you have the call() method you can find in default.py controller of welcome application then write a method like this in default.py: def dothetest(): return dict() @service.json def test(input): print type(input) return dict(type=type(input), input=input) in views/default/dothetest.html write {{extend 'layout.html'}} <script> jQuery.postJSON("{{=URL(), {'message': 'this is a test'}, function (data) { alert('received: ' + data);} </script> browse to http://localhost:8000/<app name>/default/dothetest 2015-02-20 20:03 GMT+01:00 Richard Vézina <ml.richard.vez...@gmail.com>: > but what is : > > print 'request.vars.input'?? > > To me it should print : "request.vars.input" > > hein!! > > Clara would you copy/paste your exact code here? > > Richard > > > > On Fri, Feb 20, 2015 at 2:00 PM, Richard Vézina < > ml.richard.vez...@gmail.com> wrote: > >> No a list of python dict >> >> :) >> >> Richard >> >> On Fri, Feb 20, 2015 at 1:27 PM, Derek <sp1d...@gmail.com> wrote: >> >>> It doesn't appear to be a string object anymore, you have a python >>> dictionary object. >>> Try this.. >>> >>> print type(request.vars.input) >>> >>> >>> On Friday, February 20, 2015 at 11:19:55 AM UTC-7, clara wrote: >>>> >>>> Hello, >>>> >>>> I am making an Ajax call and calling a controller with the json data I >>>> need to process in the controller. >>>> >>>> The problem I am having (and I am sure the answer will be simple and I >>>> will hate myself for the silly question ) is that if I select >>>> request.vars.input, its value is not a json object anymore so a loads >>>> method will fail. It is a string object and if I try to eval(it) I get an >>>> error. So even when the data is right there I can not use it in the >>>> controller. >>>> Any ideas will be more than welcome! >>>> >>>> (The controller and its print outs are shown bellow.) >>>> >>>> Thanks, >>>> Clara >>>> >>>> def test(): >>>> print "test called" >>>> print "test called" >>>> print 'request.vars' >>>> print request.vars >>>> print 'request.vars.input' >>>> >>>> Here is what the controller prints out: >>>> >>>> test called >>>> request.vars >>>> <Storage {'input': '[{"the_owner":1,"category":1,"name":"La marcha del >>>> oro","price":44.45,"id":1,"quantity":100},{"the_owner":3,"c >>>> ategory":3,"name":"Toy Story","price":34.56,"id":2," >>>> quantity":23},{"the_owner":2,"category":2,"name":"La >>>> Sirenita","price":56.67," >>>> id":3,"quantity":10},{"the_owner":null,"category":null," >>>> name":null,"price":null,"id":null,"quantity":null}]'}> >>>> request.vars.input >>>> [{"the_owner":1,"category":1,"name":"La marcha del >>>> oro","price":44.45,"id":1,"quantity":100},{"the_owner":3, >>>> "category":3,"name":"T >>>> oy >>>> Story","price":34.56,"id":2,"quantity":23},{"the_owner":2,"category":2,"name":"La >>>> Sirenita","price":56.67,"id":3,"quantity":10} >>>> ,{"the_owner":null,"category":null,"name":null,"price":null, >>>> "id":null,"quantity":null}] >>>> >>>> >>>> -- >>> 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 web2py+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- > 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 web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.