Nice!

On Nov 25, 1:06 pm, Alex <[email protected]> wrote:
> Could work, but is not what I expected too.
>
> Actually I found solution, if anyone will be intersted in it:
>
> request.env.http_x_requested_with
> could be str('XMLHttpRequest') on ajax request
>
> request.env.request_method
> is str('POST') or 'GET'
>
> And this what I needed :)
>
> On Nov 25, 6:42 am, "mr.freeze" <[email protected]> wrote:
>
> > Send a var back with the ajax request:
>
> > <a href="{{=URL('gym','default','get_workout')}}" onclick="ajax
> > ('{{=URL
> > (r=request,f='get_workout',vars=dict(is_ajax=True))}}', [],
> > 'fitness_goals');return false;">
> > {{=a.title}}</a>
>
> > if request.vars.is_ajax:
> >    ....
>
> > On Nov 24, 10:14 pm, Alex <[email protected]> wrote:
>
> > > But how can controller method know if current request is POST / GET or
> > > AJAX?
>
> > > Sometimes it's needed to generate very different part of HTML page and
> > > return it to update some DIV on the page.
>
> > > On Nov 25, 6:09 am, Thadeus Burgess <[email protected]> wrote:
>
> > > > On your ajax calls use the .json
>
> > > > so
>
> > > >http://mysite.com/init/default/index/fornormalpages
>
> > > >http://mysite.com/init/default/index.json/togetthedict converted to json
>
> > > > or
>
> > > > index.xml to get it in xml format..
>
> > > > -Thadeus
>
> > > > On Tue, Nov 24, 2009 at 10:06 PM, Alex <[email protected]> wrote:
>
> > > > > Hello,
>
> > > > > I have "get_workout" action in controler and this action could be
> > > > > called either directly using GET method, or could be called using
> > > > > AJAX.
>
> > > > > If it's called using GET it should return (render) whole page.
> > > > > If it's called using AJAX it should return (render) only a part of the
> > > > > page
>
> > > > > It's not clear how to do it using web2py
>
> > > > > I wanted to check inside controller method if current request it GET /
> > > > > POST or AJAX and then change the logic of the method but didn't find a
> > > > > way to check if current request is AJAX, how to do it?
>
> > > > > I use such kind of link:
> > > > > <a href="{{=URL('gym','default','get_workout')}}" 
> > > > > onclick="ajax('{{=URL
> > > > > (r=request,f='get_workout')}}', [], 'fitness_goals');return false;">
> > > > > {{=a.title}}</a>
>
> > > > > The base idea is to make partial page update using AJAX with loading
> > > > > banner displaying during update and page opening using non-AJAX
> > > > > request when whole page HTML will be loaded.
>
> > > > > What is the best way to do it?
>
> > > > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to