• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Browser Redirection and Ajax

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to ajax and I am not sure of what I am observing but hopefully somebody could give me light on this.

I notice that when I return a 302 HTTP response from a call with Jquery $.ajax() or $.json(), the browser is handling the redirection itself and I cannot get the xhr.status of 302 but always 200.

Is what i notice correct and is there any workaroubd for this? I see on my firebug the 302 response code but it is handing me a status of 200 and not the 302.



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you be sending a redirect as a result of an Ajax request?
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, i configured a servlet filter that intercepts all url request if there is session associated with it. If not, they are redirected to the login page. For non-xmlhttprequest, this works fine. But when I issue an ajax request, i cannot get hold of the 302 http response. The browser is handling it for me, and what i get is an xhr status of 200. Is my observation, correct?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check if its an XHR request before sending back the response code?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic