XMLHttpRequest: thuộc tính responseURL

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2016.

Note: This feature is available in Web Workers, except for Service Workers.

Thuộc tính chỉ đọc XMLHttpRequest.responseURL trả về URL đã được tuần tự hóa của phản hồi hoặc chuỗi rỗng nếu URL là null. Nếu URL được trả về, bất kỳ đoạn fragment URL nào có trong URL sẽ bị loại bỏ. Giá trị của responseURL sẽ là URL cuối cùng thu được sau bất kỳ chuyển hướng nào.

Ví dụ

js
const xhr = new XMLHttpRequest();
xhr.open("GET", "http://example.com/test", true);
xhr.onload = () => {
  console.log(xhr.responseURL); // http://example.com/test
};
xhr.send(null);

Các đặc tả kỹ thuật

Specification
XMLHttpRequest
# the-responseurl-attribute

Tương thích trình duyệt