有关http请求的拦截

function addXMLRequestCallback() {
    var oldSend = XMLHttpRequest.prototype.send;
    XMLHttpRequest.prototype.send = function () {
        this.addEventListener('load', function () {
             console.log('request completed!');
             //will always be 4 (ajax is completed successfully)
             console.log(this.readyState); 
             console.log(this.responseText); 
            });
                oldSend.apply(this, arguments);
            }
        }
        addXMLRequestCallback();

标签: none

添加新评论