你试试重写send方法:
$(function() { var xhr = null; if (window.XMLHttpRequest) { xhr = window.XMLHttpRequest; } else if(window.ActiveXObject('Microsoft.XMLHTTP')){ // I do not know if this works xhr = window.ActiveXObject('Microsoft.XMLHTTP'); } var send = xhr.prototype.send; xhr.prototype.send = function(data) { try{ //TODO: comment the next line console.log('pre send', data); send.call(this, data); //TODO: comment the next line console.log('pos send'); } catch(e) { //TODO: comment the next line console.log('err send', e); } }; $.ajax({ dataType: 'xml', url: "./python/perfdata.xml?sid=" + (new Date()).getTime(), success: function (data) { var protocols = $("Protocols", data).children(); parseData(protocols); }, error: function (error) { setTimeout(getData, 200); } });});
copy去编辑器看,百度回复格式有点乱。。
$(function() { var xhr = null; if (window.XMLHttpRequest) { xhr = window.XMLHttpRequest; } else if(window.ActiveXObject('Microsoft.XMLHTTP')){ // I do not know if this works xhr = window.ActiveXObject('Microsoft.XMLHTTP'); } var send = xhr.prototype.send; xhr.prototype.send = function(data) { try{ //TODO: comment the next line console.log('pre send', data); send.call(this, data); //TODO: comment the next line console.log('pos send'); } catch(e) { //TODO: comment the next line console.log('err send', e); } }; $.ajax({ dataType: 'xml', url: "./python/perfdata.xml?sid=" + (new Date()).getTime(), success: function (data) { var protocols = $("Protocols", data).children(); parseData(protocols); }, error: function (error) { setTimeout(getData, 200); } });});
copy去编辑器看,百度回复格式有点乱。。