我发现这段代码可以拦截XMLHttpRequest
(function (open) {
XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
this.addEventListener("readystatechange", function () {
if (this.readyState == 4) {
console.log(this.status);
}
}, false);
open.call(this, method, url, async, user, pass);
this.setRequestHeader("Authorization", "Token 123")
};
})(XMLHttpRequest.prototype.open);
有一种方法可以在纯JavaScript中使用HTMLFormElement
进行相同的操作吗?