gpt4 book ai didi

javascript - 从 xhr 对象获取请求 url

转载 作者:IT王子 更新时间:2023-10-29 03:11:14 28 4
gpt4 key购买 nike

有什么方法可以从 xhr 对象中提取请求 url 吗?我可以通过 channel 属性在 firebug 中看到 url,但你不能使用 javascript 查询它。

最佳答案

使用以下 hack 不需要包装器:

var xhrProto = XMLHttpRequest.prototype,
origOpen = xhrProto.open;

xhrProto.open = function (method, url) {
this._url = url;
return origOpen.apply(this, arguments);
};

用法:

var r = new XMLHttpRequest();
r.open('GET', '...', true);
alert(r._url); // opens an alert dialog with '...'

关于javascript - 从 xhr 对象获取请求 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/921198/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com