aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes jQuery ajax request and 302 status code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "jQuery ajax request and 302 status code" Watch "jQuery ajax request and 302 status code" New topic
Author

jQuery ajax request and 302 status code

Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56207
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Hi Bear,

You were right, jQuery has nothing to do with this. The browser is handling the redirect. Thanks for the help!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: jQuery ajax request and 302 status code
 
Similar Threads
AJAX lag issue
object required in java script error
JSP Action Buttons freez after returning from ajax call
jQuery autocomplete problem
Page section does not update after call of a4j:support in IE 9