There is a page (url), I request it by XMLHttpRequest, but I'm not getting response from requested url, It's directing request to another page,
requesting --- > page.php
getting reponse from > directedpage.php
and the question is how can I get response url? (directedpage.php in example)
It works by creating an XMLHttpRequest object and creating a listener for readystatechange events such that when readyState changes to DONE (4), the response is obtained and passed into the callback function provided to load() .
The read-only XMLHttpRequest. responseURL property returns the serialized URL of the response or the empty string if the URL is null . If the URL is returned, any URL fragment present in the URL will be stripped away. The value of responseURL will be the final URL obtained after any redirects.
The Response/Receipt URL(s) are the Web addresses to which the payment gateway sends transaction responses and/or redirects customers to your website from the payment gateway hosted receipt page.
Retrieving an HTML resource as a DOM using XMLHttpRequest works just like retrieving an XML resource as a DOM using XMLHttpRequest , except you can't use the synchronous mode and you have to explicitly request a document by assigning the string "document" to the responseType property of the XMLHttpRequest object after ...
The final URL (after following all redirects) is available in the responseURL
attribute of a XMLHttpRequest
instance.
This feature is new and only supported in Firefox 32 stable in September 2014 [ref] and Chrome 37.0.2031.0 stable in August 2014 [ref] (and probably also Opera 24). responseURL
is not (yet) supported in IE 11 or Safari 7 and older browsers. For these browsers, the previous answer is still true:
XMLHttpRequest
automatically follows redirects, without saving the served URLs in a property. TheLocation
header can neither be retrieved through the.getResponseHeader()
.
References:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With