On Monday, November 9, 2015 at 3:16:46 AM UTC-5, Karl Florian wrote:
>
> Thank you for your very good suggestions.
> Here is what i tried:
> Putting the script into my print_countries view worked good.
> The only Thing that bothered me was that i had to click the submit Button 
> twice.
>

I see the problem. You only have to click submit once the first time. But 
because submission does not cause the page to reload, you're stuck with the 
same CSRF token in the form, so when you attempt to submit a second time, 
the CSRF check fails, and instead you get a new page with a fresh form (and 
fresh CSRF token) -- and then the next submit works. If you don't need CSRF 
protection for this form (which you may not, given that it doesn't appear 
to be inserting anything to the database but only requesting information), 
you can disable it via form.process(session=None). Or you can implement 
your own CSRF protection with a multi-use token.
 

> The Problems i had using your alternative solution are best explained in 
> my attachment.
>

The code isn't quite right. You have get_countries as a component inside 
print_countries. Instead, print_countries should be an Ajax component 
inside a parent page (i.e., you'll have to create a new parent page whose 
only content is the print_countries component). Then get_countries is 
called via the Javascript returned by print_countries.

Anthony

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