Open ichangjun opened 3 years ago
/** *初始化请求劫持 * */ VueDataAc.prototype._initXhrErrAc = function _initXhrErrAc () { const _nativeAjaxOpen = XMLHttpRequest.prototype.open; const _nativeAjaxSend = XMLHttpRequest.prototype.send; const _nativeAjaxonReady = XMLHttpRequest.onreadystatechange; this._proxyXhrObj = { open: function () { this._ac_method = (arguments[0] || [])[0]; return (_nativeAjaxOpen && _nativeAjaxOpen.apply(this, arguments)); }, send: function () { this._ac_send_time = ac_util_getTime().timeStamp; this._ac_post_data = (arguments[0] || [])[0] || ''; this.addEventListener('error', function (xhr) { _VueDataAc._formatXhrErrorData(xhr.target); }); this.onreadystatechange = function (xhr) { _VueDataAc._formatXhrErrorData(xhr.target); _nativeAjaxonReady && _nativeAjaxonReady.apply(this, arguments); }; return (_nativeAjaxSend && _nativeAjaxSend.apply(this, arguments)); } }; XMLHttpRequest.prototype.open = this._proxyXhrObj.open; XMLHttpRequest.prototype.send = this._proxyXhrObj.send; };