• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jQuery ajax request and 302 status code

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy,

I'm making an ajax request using jQuery and if the user's session has expired the response that I get is a 302 moved. jQuery in that case is making another request to the new path which is the login page. I want to show the user a message if the status is 302 but I'm not able to achieve this. This is the code I'm using


This is not working though, jQuery is still making another request if the user is logged out. I also tried this but got the same result

Any help would be appreciated...
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not completely sure, but I think that it's the browser's Ajax implementation that is handling the redirect. if this is the case, jQuery has no power to make it act otherwise.

I'd try making the Ajax request without jQuery's help and see if the redirect is still handled the same way. If so, then there may not be much you can do about it.

If it does turn out to be jQuery that's handling the redirect on your behalf (cool feature if so), we can explore if there's a way to have it suspend such handling.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

You were right, jQuery has nothing to do with this. The browser is handling the redirect. Thanks for the help!!
reply
    Bookmark Topic Watch Topic
  • New Topic