Paco here is the reponse:

   1. {vars: {…}, respuesta: "noexiste"}
      1. respuesta: "noexiste"
      2. vars: {tarea: "solicitudguardar", items[json1]: "[1,2,3]"}
      3. __proto__: Object
   


Thanks in advance,


El miércoles, 20 de noviembre de 2019, 16:39:22 (UTC-5), Paco Bernal 
escribió:
>
> Hi,
>
> Try this, write down at the begin of the controller
>
> print request.vars
>>
>
> you will see how the controller receives the information and then you will 
> know if it's a js problem or a server side problem.
>
> with your code what the controller receives is 
>
> <Storage {'tarea': 'solicitudguardar', 'items[json1]': 
>> '{"make":"Ford","model":"Mustang","year":1969}'}>
>>
>
> you don't need to use  json.loads, you just need this
>
>>
>> mydata = request.vars['items[json1]']
>> print mydata
>> {"make":"Ford","model":"Mustang","year":1969}
>>
>
> Regards from spain Ugly Duckling :)
>
> El miércoles, 20 de noviembre de 2019, 18:08:03 (UTC+1), Patito Feo 
> escribió:
>>
>> Hi,
>>
>> Ive been trying to pass an object with keys to the controller. But i 
>> havent been able to extract the request.vars.
>>
>> Here is my view:
>>
>> var Cars = {}
>> Cars.make = 'Ford';
>> Cars.model = 'Mustang';
>> Cars.year = 1969;
>>
>> $.post( "{{=URL('default', 'transcriptor')}}", //request.post_vars.json1
>>    {     
>>          tarea: 'solicitudguardar', items: { json1: JSON.stringify( Cars 
>> ) }
>>    }, )
>>
>>
>> Here is my function:
>>
>> elif request.vars.tarea == 'solicitudguardar':
>>
>>    var = json.loads ( request.post_vars.items[json1] )
>>        
>>        
>>
>> Here is one of the errors i got:
>>
>> global name 'json1' is not defined
>>
>>
>> I dont understand why the array object is not being process as a json 
>> array in controller. 
>>
>> Any help will be much appreciated.
>>
>>
>> Cheers,
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e4f7a303-0bf6-40c6-9565-e4ec8f12918b%40googlegroups.com.

Reply via email to