慕桂英546537
如何修改XMLHttpRequest.prototype.open或发送替换方法来设置自己的回调并调用原始方法?回调可以执行其操作,然后将回调称为指定的原始代码。换一种说法:XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open;var myOpen = function(method, url, async, user, password) { //do whatever mucking around you want here, e.g. //changing the onload callback to your own version //call original this.realOpen (method, url, async, user, password);} //ensure all XMLHttpRequests use our custom open methodXMLHttpRequest.prototype.open = myOpen ;