Using jQuery to perform an ajax POST, as the page requires the user to be authenticated, sometimes (when the session expires), server responds with a 302. So I'm trying to catch that response code from the ajax and redirect to the homepage.
My ajax looks like this:
$.ajax(this.action, {
type: "POST",
data: {value:input},
statusCode: {
301: function(resp){
window.location.replace('/');
},
302: function(resp){
window.location.replace('/');
}
},
success: function(response){
$('#obtained').val(response);
},
error: function(error){
alert(error);
}
});
But for some reason the function in the 302 or any other status code never get triggered.
Is this deprecated or am I missing something?
Thanks!