1function Ajax2() { 2 //Eigenschaften deklarieren und initialisieren 3 this.url=""; 4 this.params=""; 5 this.method="GET"; 6 this.synchron=true; 7 this.onSuccess=null; 8 this.onLoad=null; 9 this.onError=function (msg) { 10 alert(msg) 11 } 12} 13 14Ajax2.prototype.doRequest=function() { 15 //Ãberprüfen der Angaben 16 if (!this.url) { 17 this.onError("Es wurde kein URL angegeben. Der Request wird abgebrochen."); 18 return false; 19 } 20 21 if (!this.method) { 22 this.method="GET"; 23 } else { 24 this.method=this.method.toUpperCase(); 25 } 26 27 //Zugriff auf Klasse für readyStateHandler ermöglichen 28 var _this = this; 29 30 //XMLHttpRequest-Objekt erstellen 31 var xmlHttpRequest=getXMLHttpRequest(); 32 if (!xmlHttpRequest) { 33 this.onError("Es konnte kein XMLHttpRequest-Objekt erstellt werden."); 34 return false; 35 } 36 37 //Fallunterscheidung nach Ãbertragungsmethode 38 switch (this.method) { 39 case "GET": xmlHttpRequest.open(this.method, this.url+"?"+this.params, this.synchron); 40 xmlHttpRequest.onreadystatechange = readyStateHandler; 41 xmlHttpRequest.send(null); 42 break; 43 case "POST": xmlHttpRequest.open(this.method, this.url, true); 44 xmlHttpRequest.onreadystatechange = readyStateHandler; 45 xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 46 xmlHttpRequest.send(this.params); 47 break; 48 } 49 50 //Private Methode zur Verarbeitung der erhaltenen Daten 51 function readyStateHandler() { 52 if (xmlHttpRequest.readyState <= 3) { 53 if (_this.onSuccess && _this.onLoad!=null) { 54 _this.onLoad(); 55 } 56 } 57 if (xmlHttpRequest.readyState < 4) { 58 return false; 59 } 60 if (xmlHttpRequest.status == 200 || xmlHttpRequest.status==304) { 61 if (_this.onSuccess) { 62 _this.onSuccess(xmlHttpRequest.responseText, xmlHttpRequest.responseXML); 63 } 64 } else { 65 if (_this.onError) { 66 if(xmlHttpRequest.status ) 67 { 68 _this.onError("["+xmlHttpRequest.status+" "+xmlHttpRequest.statusText+"] Es trat ein Fehler bei der Datenbertragung auf."); 69 } 70 else 71 { 72 //_this.onError("["+xmlHttpRequest.status+"] Es trat ein Fehler bei der Datenbertragung auf."); 73 } 74 } 75 } 76 } 77} 78 79//Gibt browserunabhängig ein XMLHttpRequest-Objekt zurück 80function getXMLHttpRequest() 81{ 82 if (window.XMLHttpRequest) { 83 //XMLHttpRequest für Firefox, Opera, Safari, ... 84 return new XMLHttpRequest(); 85 } else 86 if (window.ActiveXObject) { 87 try { 88 //XMLHTTP (neu) für Internet Explorer 89 return new ActiveXObject("Msxml2.XMLHTTP"); 90 } catch(e) { 91 try { 92 //XMLHTTP (alt) für Internet Explorer 93 return new ActiveXObject("Microsoft.XMLHTTP"); 94 } catch (e) { 95 return null; 96 } 97 } 98 } 99 return false; 100}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.