I am trying to use JavaScript Query Builder plugin (querybuilder.js.org) 
with web2py. The plugin is installed successfully and I can see the 
querybuilder object in my view. I want to finally pass the string 
containing the filters selected from the view to another controller 
function for further processing. The code I am using on the view is below:


<button onclick='myFunction();'>Get rules</button>


    function myFunction();{

        var result = 
JSON.stringify($('#builder-basic').queryBuilder('getRules'), null, 2);

        ajax('{{=URL('default', 'showfilters', 
vars=dict(result=result))}}', [], ':eval');




I want to pass ‘result’ variable to ‘showfilters’ controller function and 
call ‘showfilters’ view on clicking on ‘Get rules’ button. But the above 
code doesn’t work and gives this error:

*<type 'exceptions.NameError'> name 'result' is not defined*

I understand this could be because 'result' variable is not defined in my 
controller function corresponding to this view. What is the correct way to 
pass the value of a variable declared through Java Script to a controller 
function in web2py?

Please help me here – I am novice to both web2py and Java Script and have 
been struggling with this for quite some time. I would prefer to pass the 
variable result through dictionary and not as an argument, as it will 
contain spaces and special characters which I want to preserve in the 



- 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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to