With ajax=False (the default), the component is constructed on the server 
at the same time as the containing page and simply inserted into the page 
before it is delivered to the browser -- so there is no separate Ajax 
request for the component -- it is created and rendered along with the 
containing page. With ajax_trap=True, you are telling it to trap any form 
submissions from within the component and send them via Ajax instead of 
doing a regular post request. In that case, the original component does not 
load via Ajax, but form submissions are subsequently handled via Ajax.

Anthony

On Wednesday, February 20, 2013 1:01:22 PM UTC-5, Loïc wrote:
>
> *Niphlod*
> Yes I'm working on Windows (7 pro x64) with the default rocket webserver.
> I have tried to deploy my application on my webserver (ubuntu server + 
> nginx). The loading time is better but I still have to wait about 1 second 
> to see the content of my component.
>
> *Anthony*
> I did'nt know ajax_trap parameter.
> So I replaced
>
> {{=LOAD('default', 'newsletter.load', ajax=True)}}
>
> with
>
> {{=LOAD('default', 'newsletter.load', ajax_trap=True)}}
>
> And my component loads instantly, thank you!
>
> But I don't really understand why ajax or ajax_trap parameters change the 
> duration to load a component. Can anyone explain me?
>
>
> Le mercredi 20 février 2013 17:34:46 UTC+1, Anthony a écrit :
>>
>> You can submit a form with ajax=False as long as you have ajax_trap=True. 
>> Still, I don't see why it should take 2-3 seconds to load. I was wondering 
>> if the session was being locked by some other request (e.g., another 
>> component on the page), but doesn't sound like that's the problem.
>>
>> Anthony
>>
>> On Wednesday, February 20, 2013 10:28:10 AM UTC-5, Loïc wrote:
>>>
>>> No, this is the only component in the page...
>>> Just to be sure, I have tried to load my component with ajax=False
>>> {{=LOAD('default', 'newsletter.load', ajax=False)}}
>>> In this case, the component loads instantly. (but of course I can not 
>>> submit my form since ajax=False)
>>>
>>> Le mercredi 20 février 2013 16:07:29 UTC+1, Anthony a écrit :
>>>>
>>>> That seems slow. Are there other components on the page?
>>>>
>>>> On Wednesday, February 20, 2013 8:46:47 AM UTC-5, Loïc wrote:
>>>>>
>>>>> Hello All
>>>>>
>>>>> In my application I use the LOAD helper to insert a component in my 
>>>>> page. The component is a simple form that allows user to subscribe to the 
>>>>> newsletter.
>>>>> When I refresh the page, I see a "loading..."  message during 2 or 3 
>>>>> seconds, and then my component is loaded.
>>>>>
>>>>> As my component is very simple, I wonder if this is normal to wait 3 
>>>>> seconds before loading the component?
>>>>>
>>>>> Thank you very much
>>>>>
>>>>>
>>>>> ######## View 'render_page.html' ########
>>>>> {{extend 'layout.html'}}
>>>>>
>>>>>
>>>>> {{block footer}}
>>>>>     <!-- Newsletter -->
>>>>>     {{=LOAD('default', 'newsletter.load', ajax=True)}}
>>>>> {{end}}
>>>>>
>>>>>
>>>>> ###############################
>>>>>
>>>>> ######## Controller 'default.py' #########
>>>>> def newsletter():
>>>>>     """
>>>>>     Allows to access the "newsletter" component
>>>>>     """
>>>>>     form = SQLFORM(db.registered_user, _class='blueText')
>>>>>     if form.process().accepted:
>>>>>        response.flash = T('form accepted')
>>>>>     elif form.errors:
>>>>>        response.flash = T('form has errors')
>>>>>     return dict(form=form)
>>>>>
>>>>>
>>>>> ###################################
>>>>>
>>>>> ######### Component 'newsletter.load' #########
>>>>> <div class="newsletter pull-right">
>>>>>     <div><h3>Newsletter</h3></div>
>>>>>     {{if not session.REGISTERED_EMAILS:}}
>>>>>         <p>{{=T('Please insert your email adress to receive our 
>>>>> latest news')}}</p>
>>>>>         {{=form}}
>>>>>     {{else:}}
>>>>>         <h5>{{=T('Registered email : %s' 
>>>>> %(session.REGISTERED_EMAIL))}}</h5>
>>>>>     {{pass}}
>>>>> </div>
>>>>> <script>jQuery('input[type="text"]').css('width','100%');</script>
>>>>>
>>>>>
>>>>> ##########################################
>>>>>
>>>>>

-- 

--- 
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/groups/opt_out.


Reply via email to