0

我需要在readyState4 时获取标题。

我有这个代码:

    <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>

可能吗?

4

1 回答 1

0

您可以使用getResponseHeader().

于 2013-06-01T12:27:16.400 回答