function AJAXConnection(newURL, newParameters) { this.onchange = null; this.ie = false; this.url = newURL; this.parameters = newParameters; this.body = null; this.callbackfunction = null; if (typeof(_AJAXConnection_prototype_called) == 'undefined') { _AJAXConnection_prototype_called = true; AJAXConnection.prototype.setRequestTag = setRequestTag; AJAXConnection.prototype.getRequestTag = getRequestTag; AJAXConnection.prototype.setCallbackFunction = setCallbackFunction; AJAXConnection.prototype.getResponseText = getResponseText; AJAXConnection.prototype.getResponseXML = getResponseXML; AJAXConnection.prototype.callBack = callBack; AJAXConnection.prototype.get = get; AJAXConnection.prototype.post = post; } function setRequestTag(newBody) { this.body = newBody; } function getRequestTag() { return this.body; } function setCallbackFunction(newCallbackfunction) { this.callbackfunction = newCallbackfunction; } function getResponseText() { if (this.rpc_request != null) return this.rpc_request.responseText; else return null; } function getResponseXML() { if (this.rpc_request != null) return this.rpc_request.responseXML; else return null; } function callBack(self) { if (self != null && self.rpc_request.readyState == 4) { if (self.callbackfunction != null) self.callbackfunction(); } } function get(wait) { if (wait == null) wait = true; this.rpc_wait = wait; var self = this; if (window.XMLHttpRequest) { this.rpc_request = new XMLHttpRequest(); this.rpc_request.onreadystatechange = function() { self.callBack(self); } } else if (window.ActiveXObject) { this.ie = true; this.rpc_request = new ActiveXObject("Microsoft.XMLHTTP"); if (this.rpc_request) this.rpc_request.onreadystatechange = function() { self.callBack(self); } } this.rpc_request.open("GET", this.url, !this.rpc_wait); if (this.ie) this.rpc_request.send(); else this.rpc_request.send(null); } function post(wait) { if (this.parameters == null) this.parameters = ""; if (this.url) { var self = this; if (wait == null) wait = true; if (window.XMLHttpRequest) { this.rpc_request = new XMLHttpRequest(); this.rpc_request.onreadystatechange = function() { self.callBack(self); } this.rpc_request.open("POST", this.url, !wait); this.rpc_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); this.rpc_request.setRequestHeader("Content-length", this.parameters.length); this.rpc_request.setRequestHeader("Connection", "close"); this.rpc_request.send(this.parameters); } else if (window.ActiveXObject) { this.rpc_request = new ActiveXObject("Microsoft.XMLHTTP"); if (this.rpc_request) { this.rpc_request.onreadystatechange = function() { self.callBack(self); } this.rpc_request.open("POST", this.url, !wait); this.rpc_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); this.rpc_request.setRequestHeader("Content-length", this.parameters.length); this.rpc_request.setRequestHeader("Connection", "close"); this.rpc_request.send(this.parameters); } } } } }