Hi ajax('{{=URL('default', 'showfilters')}}' + '?result1=' + result1 + '&result2='+result2, [], ':eval');
result1 = request.vars.result1 result2 = request.vars.result2 or ajax('{{=URL('default', 'showfilters')}}/' + result1 + '/' + result2, [], ':eval'); result1 = request.args(0) result2 = request.args(1) to will need to take care about the strings you pass to the url or you will bad results back to the app. ajax('{{=URL('default','save_user')}}/'+agent_id+'?first_name='+encodeURIComponent($('#first_name').val())+'&last_name='+encodeURIComponent($('#last_name').val())+'&email='+encodeURIComponent($('#email').val())+'&phone='+encodeURIComponent($('#phone').val()),[],':eval'); > Regards El jueves, 1 de agosto de 2019, 3:32:40 (UTC+2), Aydin escribió: > > Anthony, how to pass multiple variables, say result1 and result2? > > On Thursday, September 22, 2016 at 2:18:01 PM UTC-4, Anthony wrote: >> >> "result" is a Javascript variable, so it does not exist in the Python >> context in which the URL() function is evaluated. Instead, you must add >> that part of the URL via Javascript: >> >> ajax('{{=URL('default', 'showfilters')}}' + '?result=' + result, [], >> ':eval'); >> >> Anthony >> >> On Thursday, September 22, 2016 at 8:49:47 AM UTC-4, Madhavi wrote: >>> >>> Hi, >>> >>> >>> >>> 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> >>> >>> <script> >>> >>> function myFunction();{ >>> >>> var result = >>> JSON.stringify($('#builder-basic').queryBuilder('getRules'), null, 2); >>> >>> ajax('{{=URL('default', 'showfilters', >>> vars=dict(result=result))}}', [], ':eval'); >>> >>> } >>> >>> </script> >>> >>> >>> >>> 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 >>> string. >>> >>> Thanks, >>> >>> Madhavi >>> >> -- 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 web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b4b76238-b689-422c-af77-85537e5e3d6a%40googlegroups.com.