在 Js 中统一设置请求参数的另一种方法

  • 重写方法XMLHttpRequest.prototype.send
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.send = function (params) {
	var attached_params = mdcUtil.MDC_DEVICE_ID + "=" + mdcUtil.getMdcDeviceId();
	if (params) {
		params += "&" + attached_params;
	} else {
		params = attached_params;
	}
	return this._send(params)
}
0%