Javier,
Tested and not working.
<type 'exceptions.TypeError'> 'builtin_function_or_method' object has no
attribute '__getitem__'
request.post_vars <Storage {'tarea': 'solicitudguardar', 'items[json1]':
'[1,2,3]'}>
Any ideas?
Thanks for your reply,
El miércoles, 20 de noviembre de 2019, 12:35:38 (UTC-5), Javier Pepe
escribió:
>
> You need use:
>
> var = json.loads ( request.post_vars.items[*"*json1*"*] )
>
>
> El mié., 20 de nov. de 2019 a la(s) 14:08, Patito Feo ([email protected]
> <javascript:>) 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 [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/cb71d997-01f3-4dd3-b689-35c280e035b7%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/web2py/cb71d997-01f3-4dd3-b689-35c280e035b7%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/fbcef80d-d1ae-4cae-b22a-5fa10eb5156a%40googlegroups.com.