Var Pool_xmlreq = function (){
Var _ cacheCase = [];
_ CacheCase. fetch = function (){
Var I = 0;
Var _ instance = function (){
Try {
Return (new ActiveXObject ("Msxml2.XMLHTTP. 5.0 "));}
Catch (e ){
Try {
Return (new XMLHttpRequest ());}
Catch (e ){
Try {
Return (new ActiveXObject ("Msxml2.XMLHTTP "));}
Catch (e ){
Try {
Return (new ActiveXObject ("Microsoft. XMLHTTP "));}
Catch (e ){
Alert ("Error: initializing xmlhttprequest! ");}}}}}
For (; I <this. length; I ++ ){
If (this [I]. readyState = 0 | this [I]. readyState = 4 ){
Return this [I] ;}}
This [I] = _ instance ();
Return this [I];}
This. length = function (){
Return _ cacheCase. length}
This. instance = function (){
Return _ cacheCase. fetch ()}
This. connect = function (method, url, data, handler ){
Var _ xmlhttpreq = _ cacheCase. fetch ();
With (_ xmlhttpreq ){
Open (method, url, true );
SetRequestHeader ("Cache-Control", "no-cache ");
SetRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset = UTF-8 ");
Send (data );
Onreadystatechange = function (){
If (_ xmlhttpreq. readyState <4)
Return false;
If (_ xmlhttpreq. status = 200 | _ xmlhttpreq. status = 304 ){
Handler (decodeURIComponent (_ xmlhttpreq. responseText ));
Return true ;}
Alert ("Error: status _" + _ xmlhttpreq. status + "! ");
Return false ;}}}
}
Var xmlreq = new Pool_xmlreq ();
Usage:
Xmlreq. connect ("post", url, postdata, function );