request.vars & JQuery params

35 views
Skip to first unread message

Val K

unread,
May 12, 2016, 8:44:14 AM5/12/16
to web2py-developers

Hello!

I have a question  about web3py.  jQuery says:

"As of jQuery 1.4, the $.param() method serializes deep objects recursively to accommodate modern scripting languages and frameworks such as PHP and Ruby on Rails. You can disable this functionality globally by setting jQuery.ajaxSettings.traditional = true;.

As of jQuery 1.8, the $.param() method no longer uses jQuery.ajaxSettings.traditional as its default setting and will default to false. For best compatibility across versions, call $.param() with an explicit value for the second argument and do not use defaults."

it means, that

 $.param({list:[ {var1:1, var2:2}, {var1:1, var2:2} ]} )
will be serialised like:  "list[0][var1]=1&list[0][var2]=2..."

At the moment, web2py treats such post as Storage of  {"list[0][var1]": "1", "list[0][var2]":"2" ...} 

but would be better:

{"list": [{"var1": "1", "var2": "2"}, {"var1": "1", "var2": "2"}]}

I saw web3py source  - it seems, there are nothing new (maybe I missed something?)

P.S. I have one  sketch








Niphlod

unread,
May 12, 2016, 3:16:06 PM5/12/16
to web2py-developers
on my side I'd be quite happy to accomodate for arrays specified as id[]=1 but not on a spec concocted by jquery team. 
Those nested objects are far better (and yet readily) parsed if posted with application/json content-type, which is a consolidated spec.
Reply all
Reply to author
Forward
0 new messages