>
> What do you mean with bei -The code isn't quit right-.
> I don't have get_countries as a component inside print_countries as far as
> i know.
>
Yes, the LOAD() helper creates a component. In your print_countries view
file, you have this line:
{{=LOAD('default','get_countriespdf.load',ajax=True,target='get_countriespdf')}}
This doesn't make sense, as get_countriespdf returns a download file, so it
would not be a component on the page. Rather it is the print_countries
action that should be converted to a component (so the form submission
happens via Ajax). So, something like:
def parent_page():
return dict(countries_component=LOAD('default', 'print_countries.load',
ajax=True))
parent_page.html view:
{{extend 'layout.html'}}
{{=countries_component}}
Then you'll need a print_countries.load view that does not extend the
layout.
Of course, you can change the name of parent_page to print_countries, and
then rename your current print_countries function to something else (the
name doesn't matter too much, as the user will not see its URL in the
browser, as it is an Ajax component).
Anthony
Do i have to make a view file for the get_countries function?
> I am new to web2py and web programing (after years of developing Desktop
> database applications) so i need examples or more Information.
> Where do i put the LOAD(..., ajax=True and what is the procedure behind
> the seen? Please give me an example.
>
> You have been very helpful, thank you.
>
> Karl
>
> Am Montag, 9. November 2015 13:25:46 UTC+1 schrieb Anthony:
>
>> 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 submsit 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.