I am working on an AJAX script that makes a GET request to an abbreviated URL, such as a bit.ly link. How can I get the URL of the final / redirected page?
I can get response headers from a redirected page, but it does not contain URL information:
$.ajax({ url: "http://www.thislinkredirects.com", success: function(data, status, xhr) { var response = $(data); }, complete: function(xhr) { console.log(xhr.getAllResponseHeaders()); } });
Result:
Date: Tue, 23 Jun 2015 03:22:07 GMT Allow: POST, GET, OPTIONS, PUT, DELETE Server: lighttpd/1.4.35 X-Powered-By: PHP/5.3.3 Transfer-Encoding: chunked Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE Content-type: text/html Access-Control-Allow-Origin: * Access-Control-Allow-Headers: accept, authorization
I have no control over the server making the receive request.
source share