function myTT_clsAjax() { this.fUrl = ""; this.fParams = ""; this.fMethod = "GET"; this.fXML = null; this.onSuccess = null; this.onError = myTT_clsAjax_OnError; this.onRequest = myTT_clsAjax_OnRequest; function myTT_clsAjax_OnError(aMessage) { alert(aMessage); } function myTT_clsAjax_OnRequest() { if(!this.fUrl) { this.onError("Es wurde kein URL angegeben. Der Request wird abgebrochen."); return false; } if(!this.fMethod) this.fMethod = "GET"; else this.fMethod = this.fMethod.toUpperCase(); var _this = this; var xmlHttpRequest = myTT_clsAjax_XMLHttpRequest(); if(!xmlHttpRequest) { this.onError("Es konnte kein XMLHttpRequest-Objekt erstellt werden."); return false; } switch(this.fMethod) { case "GET" : xmlHttpRequest.open(this.fMethod, this.fUrl+"&"+this.fParams, true); xmlHttpRequest.onreadystatechange = myTT_clsAjax_ReadyStateHandler; xmlHttpRequest.send(null); break; case "POST": xmlHttpRequest.open(this.fMethod, this.fUrl, true); xmlHttpRequest.onreadystatechange = myTT_clsAjax_ReadyStateHandler; xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttpRequest.send(this.fParams); break; } function myTT_clsAjax_ReadyStateHandler() { if (xmlHttpRequest.readyState < 4) { return false; } if (xmlHttpRequest.status == 200 || xmlHttpRequest.status==304) { if (_this.onSuccess) { _this.onSuccess(xmlHttpRequest.responseText, xmlHttpRequest.responseXML); } } else { if (_this.onError) { _this.onError("["+xmlHttpRequest.status+" "+xmlHttpRequest.statusText+"] Es trat ein Fehler bei der Datenbertragung auf."); } } } } function myTT_clsAjax_XMLHttpRequest() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else { if (window.ActiveXObject) { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { return null; }}} return false; }}}