On Oct 13, 2011, at 6:08 AM, juanduke wrote:

> Have a question (possible very simple).
> 
> In my view, I've some js code that append data to a js array like this:
> myarray.push({someKey: "someValue", anotherKey: "another value"})
> after a few pushes, I'm gettin an array like this
> myarray[0] : {someKey: "someValue", anotherKey: "another value"}
> myarray[1] : {someKey: "someValue2", anotherKey: "another value2"}
> 
> This is going fine, but at some point need to send this data to some 
> controller to load something
> So using jquery.load (url to controller, { data: myarray }, function(){ ...do 
> something.. }
> A can see  (with firebug) the request vars is something like: (this format is 
> jquery's magic i think)
> 
> myarray[0][somekey]: someValue
> myarray[0][anotherKey]: anotherKey
> myarray[0][somekey]: someValue2
> myarray[0][anotherKey]: anotherKey2
> 
> This goes excelent, at the point to get this variables values from the 
> request object in the controller
> if using 
>   request.vars.myarray
>   request.vars.myarray[0]
>   request.vars.myarray[0][somekey] 
> and similars, generate a ticket sayin that is NoneType
> 
> if I list vars with request.vars.getlist, get vars and values as expected, 
> and using get_vars['myarray[0][somekey]'] return a ticket saying 
> TypeError: 'NoneType' object is unsubscriptable
> 
> I hope to be clear. Help is apreciated, and sorry for my bad english!!
> 

request.vars isn't going to be very good at handling complex data structures 
like this--anything but a string dictionary, really.

One approach might be to JSON-encode myarray before you make the load call: 
jQuery.load(url, { data:myarray_encoded }, ...

...and then decode the result in your controller.

Reply via email to