the default function that you're using (ajax()) defined in web2py.js can't handle the "please restrict only to this formname" scenario. it's a bad design choice to have the same input names for different forms. It's a bad design choice to have the same formname for different forms (because of possible CRSF issues). But, everyone has a choice ^_^ ... you can copy the ajax function and create your own (e.g. appname_ajax) and use that instead ....
Il giorno venerdì 10 maggio 2013 12:27:11 UTC+2, Mika Sjöman ha scritto: > > Hi > > I am having a problem because my forms are getting sent with multiple > values. The issue is that on my page there are multiple places where the > same formnames are used. So the post vars becomes like this: > > Parametersapplication/x-www-form-urlencoded > answer280lesson75lesson75lesson75player_answer > quiz96quiz96streak7streak7streak7 > Source > > player_answer=&answer=280&streak=7&streak=7&streak=7&quiz=96&quiz=96&lesson=75&lesson=75&lesson=75 > The above is created by> > > jQuery('#add_quiz_option').submit(function() { > ajax('{{=URL(c='quiz',f='add_inline_answer')}}', > ['description', 'is_correct', 'quiz', 'streak', > 'lesson'], 'quiz_answers'); > return false; > }); > > On the server I could do a check if they are lists and then chop them > down, but that is REALLY messy. Is this a design flaw from my perspective > or is there a way to solve this better than renaming the vars and them > renaming them to the matching corresponding database field names when the > function receives the request.vars? > > Starting to get really messy in my code now because I use ajax/jquery > calls allot. I could rename the form names, but that forces me to rename > them again after I receive them at the server. Is there a simple way to > tell jQuery to only use the values from a specific FORM-name so it will not > send the same value 5 times? > > Cheers > -- --- 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/groups/opt_out.