1/* 2Ajax ç±» 3sUrl : ç®æ URL 4sQueryString : æäº¤åé 5callbackFunc : åè°å½æ° 6callbackParams : åè°å½æ°åæ° 7sRecvType : è¿å弿 ¼å¼ ( 0: ææ¬, 1: XML ); 8*/ 9 10function Ajax ( sUrl, sQueryString, callbackFunc, callbackParams, sRecvType ) 11{ 12 this.Url = sUrl; 13 this.QueryString = sQueryString != null ? sQueryString : ''; 14 this.response; // è¿åå¼ 15 16 this.XmlHttp = this.createXMLHttpRequest (); 17 if ( this.XmlHttp == null ) 18 { 19 alert ( "ç½ç»è¿æ¥åºé, 请éè¯!" ); 20 return; 21 } 22 var objxml = this.XmlHttp; 23 objxml.onreadystatechange = function () 24 { 25 Ajax.handleStateChange ( objxml, sRecvType, callbackFunc, callbackParams ) 26 } 27} 28 29Ajax.prototype.createXMLHttpRequest = function () 30{ 31 try 32 { 33 return new ActiveXObject ( "Msxml2.XMLHTTP" ); 34 }catch(e) {} 35 36 try 37 { 38 return new ActiveXObject ( "Microsoft.XMLHTTP" ); 39 } catch(e) {} 40 41 try 42 { 43 return new XMLHttpRequest (); 44 } catch(e) {} 45 46 return null; 47} 48 49Ajax.prototype.createQueryString = function () 50{ 51 var queryString = ''; 52 if ( this.QueryString != null && typeof ( this.QueryString ) != 'string' ) 53 { 54 var elements = this.QueryString.elements; 55 var pairs = new Array(); 56 for(var i=0;i<elements.length;i++){ 57 if((name=elements[i].name)&&(value = elements[i].value)){ 58 pairs.push(name + "=" + encodeURIComponent(value)); 59 } 60 } 61 queryString = pairs.join ("&"); 62 } 63 else 64 { 65 queryString = this.QueryString; 66 } 67 return queryString; 68} 69 70Ajax.prototype.get = function () 71{ 72 sUrl = this.Url; 73 var queryString = sUrl + ( sUrl.indexOf ('?') > 0 ? '&' : '?' ) + this.createQueryString(); 74 this.XmlHttp.open ( "GET", queryString, true ); 75 this.XmlHttp.send ( null ); 76} 77 78Ajax.prototype.post = function () 79{ 80 var sUrl = this.Url; 81 var queryString = this.createQueryString (); 82 this.XmlHttp.open ( "POST", sUrl, true ); 83 this.XmlHttp.setRequestHeader ( "Content-Type","application/x-www-form-urlencoded" ); 84 this.XmlHttp.send ( queryString ); 85} 86 87Ajax.handleStateChange = function ( XmlHttp, sRecvType, callbackFunc, callbackParams ) 88{ 89 if ( XmlHttp.readyState == 4 ) 90 { 91 if ( XmlHttp.status == 200 ) 92 { 93 Response = sRecvType ? XmlHttp.responseXML : XmlHttp.responseText; 94 if ( callbackFunc != null ) 95 { 96 callbackFunc ( Response, callbackParams ); 97 } 98 } 99 else 100 { 101 // alert ( "æ¨è¿æ²¡æç»éæè ç»éå·²ç»è¶ æ¶, 请ç»éåéè¯!" ); 102 } 103 } 104}
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.