// This library handles a single Ajax request at a time. If we want our script to be // able to handle multiple outstanding requests then we will have to create wrapper // objects for XMLHttpRequest that will store additional information, such as // which callback function to call. Unfortunately // ajaxRequest: Sets up a request function ajaxRequest(send_type, url, params, callback) { var ajaxreq=false; if ( window.XMLHttpRequest ) { ajaxreq = new XMLHttpRequest(); } else if( window.ActiveXObject ) { ajaxreq = new ActiveXObject( "Msxml2.XMLHTTP" ) || new new ActiveXObject( "Microsoft.XMLHTTP" ); } if (ajaxreq == null) { alert("Your browser does not support AJAX!"); return false; } ajaxreq.onreadystatechange = ajaxResponse; ajaxreq.callback = callback; if (send_type == "GET") { ajaxreq.open("GET", url + (params ? "?" + params : "")); ajaxreq.send(null); } else { ajaxreq.open("POST", url); ajaxreq.send(params); } return ajaxreq; } // ajaxResponse: Waits for response and calls a function function ajaxResponse() { if (this.readyState != 4) return; if (this.status==200) { // if the request succeeded... if (this.callback) { this.callback(); } } else alert("Request failed: " + this.statusText); return true; }