1

I'm trying to detect 302 redirect on ajax response:

$(document).on("pfAjaxComplete", function(event, xhr, options) {
   console.log("complete",event, xhr, options);
});

This is working fine for normal ajax requests, but when I get 302 response xhr object is empty:

readyState    0
responseText    ""
responseXML    null
status        0
statusText   "error"

How can I detect 302 response? I'm using PF 4.0

karolkpl
  • 2,189
  • 10
  • 39
  • 60
  • What is the functional usecase? The reason I ask this is that maybe you try to solve something that can be better solved in a different way – Kukeltje Feb 06 '15 at 16:19
  • After SSO session timeout user is redirected with 302 to login page. This happens outside my application so I can't use any server side filter and I can't change 302 to partial response. The only way is to make new GET (eg `window.location.reload()`) request on 302 response from js – karolkpl Feb 06 '15 at 19:49
  • Tha ajax call originates in your application but the destination is outside your application? Or is a generic filter intercepting the call and sending the 302? If that filter is from your own organization, I'd ask them to change it and detect if it is an ajax call and send a partial respons. That is where it should be solved imo. See also http://stackoverflow.com/questions/6254219/jquery-ajax-request-302-redirect-what-callbacks-are-available – Kukeltje Feb 06 '15 at 22:08
  • This is some kind of proxy between browser and my application. This proxy can stop forwarding requests and replay with 302 to user. I have no control of it. The link you provided concerns using $.ajax calls manually - it's not my case, I use Primefaces 4.0 – karolkpl Feb 06 '15 at 23:29
  • Ok, if it sits in between and you cannot request them to change the proxy to detect an ajax response and return a partial-submit, then other solutions are needed. And yes the link is about jquery, but PF uses jquery and if you look at the PF source, you can override the PF behaviour and maybe add some functionality – Kukeltje Feb 07 '15 at 10:01

0 Answers0