我需要在readyState
4 时获取标题。
我有这个代码:
<script type='text/javascript'>
var open = window.XMLHttpRequest.prototype.open,
send = window.XMLHttpRequest.prototype.send,
onReadyStateChange;
var sendReplacement = function(data) {
console.log('Sending HTTP request data : ', data);
if (this.onreadystatechange) {
this._onreadystatechange = this.onreadystatechange;
}
this.onreadystatechange = onReadyStateChangeReplacement;
return send.apply(this, arguments);
};
var onReadyStateChangeReplacement = function() {
// GET HEADERS
console.log('HTTP request ready state changed : ' + this.readyState);
if (this._onreadystatechange) {
return this._onreadystatechange.apply(this, arguments);
}
};
window.XMLHttpRequest.prototype.send = sendReplacement;
</script>
可能吗?