I am using Ajax to post a user subscription data to backend. Based on the information provided by the user server can respond with either 302 (success) or 200 (failure). My Ajax request is below:
$.ajax({
url : form.action,
type: "POST",
data: $('#real-payment-form').serialize(),
complete: function(xhr,textStatus){
console.log("complete")
console.log(xhr.status)
if (xhr.status = '302'){
$('#payment-confirmation').modal()}
}
else {
alert('wrong details')}
})
}
But whatever the server responds with xhr.status is always 200. Can anyone point out what I am doing wrong. How can I pick up the 302 requests using ajax.