Answered on SO: http://stackoverflow.com/a/34903626/440323

On Thursday, January 21, 2016 at 5:24:00 PM UTC-5, Ben Wolski wrote:
>
> Here is the relevant snippet from my Web2Py view:
>
>
> {{for candidate in rows:}}
>     <div class="well col-sm-12">
>         <button type="button" name="up_button" 
> onclick="ajax('{{=URL('default', 'arrow_button_callback')}}', ['name'], 
> 'target')" class="fa fa-caret-up arrow-up fa-4x"></button>
>         <span>{{=candidate.votes}}</span>
>         <button type="button" name="down_button" 
> onclick="ajax('{{=URL('default', 'arrow_button_callback')}}', ['name'], 
> 'target')" class="fa fa-caret-down arrow-down fa-4x"></button>
>         {{=IMG(_src=URL('photos',candidate.path_to_photo), _alt="Photo of 
> Candidate")}}
>         {{=candidate.name}}
>         <div id="target"></div>
>    </div>{{pass}}
>
> And the relevant snippet from my Web2Py controller:
>
> def arrow_button_callback():
>     response.flash = str(request.post_vars.name)
>     return request.post_vars.name
>
> So why do I see the string "None" in my target div (and in my flash)?
>
>
> Thank you for your help. I read chapter 11 of the Web2Py book and I'm 
> still confused.
>
>
> I really want to be able to pass candidate.id (depending on which row's 
> button was pressed) and the button direction to controller variables. 
> Please let me know if there's a better way to do this.
>
>
> --Benjamin
>
>
> stack overflow crosspost 
> <http://stackoverflow.com/questions/34894755/why-does-this-web2py-ajax-call-fail-to-return-the-value-of-a-variable>
>

-- 
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.

Reply via email to