well....it's not how HTTP works ^_^ . Parameters (vars in web2py) needs to
either be passed as url-encoded strings or multipart bodies, or json
bodies, and the correct content-type must be provided for POST requests.
Back to your problem. If you want "request.vars.graph_data" to hold a
dictionary automatically, you need to craft your ajax call as a json POST
because there's no other way to do it either with url-encoding and
multipart/* bodies. You need to use jquery directly for that because web2py
doesn't provide any facility to do it. Before starting to mess with js
code, are you a tabble bit "js fluent" ? If not, you'd better rewrite
eco_reports() expecting the usual key-value dict in request.vars instead.
On Monday, June 9, 2014 12:02:00 AM UTC+2, Avi A wrote:
>
> Hi,
> I want to pass a dict in ajax function like that:
> $("#create_report").click(function(){
> url_report = 'eco_reports?graph_data={{=graph_data}}';
> ajax(url_report, '', 'save_as_link');
>
> and the controller starts with something like that:
> def eco_reports()::
> for item in (request.vars.graph_data):
> something item.f_test_name
> ......
>
> The error I get:
>
> AttributeError: 'str' object has no attribute 'f_test_name'
>
> what's the way to do what I Want?
>
> thanks
>
>
>
>
>
>
>
--
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].
For more options, visit https://groups.google.com/d/optout.