Is there a way to see the final URL received by XMLHttpRequest?

I am doing an AJAX download that is being redirected. I would like to know the final destination URL to which the request was redirected. I use jQuery, but also have access to the underlying XMLHttpRequest. Does anyone know a way to get the final url?

It seems I need the final target to insert its URL into a known place in the headers or response body, then find the script for it there. I was hoping to get something that works regardless of purpose.

Additional note: I ask how my code can get the full url from production code that will run from the user system. I am not asking how can I get the full url when I debug.

+3
source share
3 answers

The easiest way to do this is to use Fiddler or Wireshark to check HTTP traffic. Use Fiddler on the client if your interface uses a browser, otherwise use Wireshark to capture traffic on the wire.

0
source

One word is Firebug, it is a plugin for Firefox. Never do any AJAX development without it.

Activate Firebug and select "Network", then execute the AJAX request. This will show the URL that is being called, the entire request (header and body) and the entire response (again, header and body). It also allows you to execute your JavaScript and debug it - breakpoints, clocks, etc.

0
source

I will make the second proposal of Firebug. You will see the URL as the “Location” header in the http response. Looks like you want to get this url in js too? If so, you can get it from the xhr response object in the callback (which you can also check with FB!). :)

0
source

Source: https://habr.com/ru/post/1723832/


All Articles