[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-17 Thread eimantas
another solution would be to launch a client-side javascript timeout function that redirects user to login/signup page after session validity time has passed (say, 15 minutes). this way user wouldn't need to be redirected after clicking a link. in one site i saw a similar solution: - user opens a

[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-17 Thread candlerb
Many thanks for your input - this is now working perfectly. For the benefit of the archives: - In the server, where the session expiry is detected, I check for XMLHttpRequest ("request.xhr?" in Rails) - If so, I send back a 403 instead of the redirect to the login page - At the client side, I hav

[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-16 Thread Nick Fitzsimons
2009/7/16 Nick Fitzsimons : > 403 Forbidden [1] Oops, forgot the link :-( [1] -- Nick Fitzsimons http://www.nickfitz.co.uk/

[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-16 Thread Nick Fitzsimons
2009/7/15 candlerb : > > The login page gets inserted into the DOM, so I know the client must > be chasing the redirect and I must be getting either "success" or > "notmodified" in status. Looking at jQuery source, this comes from > xhr.status (in function httpSuccess) which gives "success" for 2x

[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-15 Thread James
jQuery does send the header: X-Requested-With: XMLHttpRequest so you can check for that on the server-side. On Jul 15, 11:47 am, candlerb wrote: > My complete() callback looks like this: > >       complete: function(res, status) { >         if ( status == "success" || status == "notmodified" )

[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-15 Thread candlerb
My complete() callback looks like this: complete: function(res, status) { if ( status == "success" || status == "notmodified" ) { node.replaceWith(res.responseText); } else { // Error handling here } } The login page gets inserted i

[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-15 Thread Brett Ritter
On Wed, Jul 15, 2009 at 12:38 PM, candlerb wrote: > Is there any way to be able to detect in $.ajax whether the response > involved a HTTP redirect? A redirect should return some form of 30x Header (as opposed to a 200 OK). You can check that, which is more elegant than looking for login page te