Alan A
Alan A

Reputation: 2551

302 Redirect Header Location

I am submitting a form via an Ajax call to a 3rd party server. I have to include a return url as hidden data type in the form. Upon submit the 3rd party processes the data and redirects via a 302 response to the url which I specify.

Is there anyway for me to read the header location redirect url, I can see it in the header response in developer tools but can't read the data into a variable as follows:

$.ajax({
      url:'https://3rdparty.com/somescript.php',
      type:'POST',
      data:myVar,
      crossDomain: true,
      success:function(reply){
           alert(reply.getResponseHeader("Location"));
      }

});

Thank you in advace.

Alan.

Upvotes: 0

Views: 2353

Answers (1)

Rafa Paez
Rafa Paez

Reputation: 4860

Change your success function to something like this

success: function(data, status, xhr) {
    alert(xhr.getResponseHeader('Location'));
}

If that does not work, check out this thread

Upvotes: 1

Related Questions