// Refactor XMLHttpRequest
VaR net = new object (); // The parameter net. ready_state_uninitialized = 0; net. ready_state_loading = 1; net. ready_state_loaded = 2; net. ready_state_interactive = 3; net. ready_state_complete = 4; net. contentloader = function (URL, onload, onerror) {// structure function number this. url = URL; this. req = NULL; this. onload = onload; this. onerror = (onerror )? Onerror: This. defaulterror; this. loadxmldoc (URL);} net. contentloader. prototype = {loadxmldoc: function (URL) {// rename the initxmlhttprequest function if (window. XMLHttpRequest) {// reconstructs the loadxml function this. req = new XMLHttpRequest ();} else if (window. activexobject) {This. req = new activexobject ("Microsoft. XMLHTTP ");} If (this. REQ) {try {var loader = this; this. req. onreadystatechange = function () {loader. onre Adystate. call (loader);} This. req. open ('get', URL, true); // reconstructs the sendrequest function this. req. send (null);} catch (ERR) {This. onerror. call (this) ;}}, onreadystate: function () {// re-structured response function var Req = This. REQ; var ready = req. readystate; If (ready = net. ready_state_complete) {var httpstatus = req. status; If (httpstatus = 200 | httpstatus = 0) {This. onload. call (this);} else {This. onerror. call (Th Is) ;}}, defaulterror: function () {alert ("error fetching data! "+" \ N \ nreadystate: "+ this. req. readystate + "\ nstatus:" + this. req. status + "\ nheaders:" + this. req. getAllResponseHeaders () ;}} function mycallback () {alert {This. URL + "loaded! Here's the content: \ n "+ this. Req. responsetext };}