XMLHttpRequest的正确时间计算

时间:2015-03-17 18:39:11

标签: javascript

我使用下面的代码来获取chrome webRequest中的计算。以下是我想要计算的值,如this

request.addEventListener("readystatechange", function () {
    var time = Date.now();
    // this.startedDateTime refers when send is called.
    switch (this.readyState) {
        case 1:
            this.startedDateTime = (new Date()).toISOString();
            break;
        case 2:
            this._$connect = time;
            this._send = (time - (new Date(this.startedDateTime)).getTime());
            this._connect = (time - (new Date(this.startedDateTime)).getTime());
            break;
        case 3:
            this._wait = time - this._$connect;
            this._$wait = time;
            break;
        case 4:
            this._receive = (time - this._$wait) || 0;
            this._time = (time - (new Date(this.startedDateTime).getTime()));
            break;
    }
});

但是当我调试它时似乎不正确。如何才能正常工作。

0 个答案:

没有答案