// ********************************************************
// AjaxComm 1.1 for Asp.Net
// Designed by Faib Studio.
// Copyright 2007
// Email faib920@126.com or QQ 55570729
// ********************************************************
function AjaxComm()
{
this.xmlHttp = null;
var clsids = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP.2.6","Microsoft.XMLHTTP.1.0","Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];
for(var i=0; i<clsids.length && this.xmlHttp == null; i++)
{
try{
this.xmlHttp = new ActiveXObject(clsids[i]);
} catch(ex) {};
};
};
AjaxComm.prototype.open = function (metohod, url)
{
if(this.xmlHttp)
{
if(this.xmlHttp.readyState == 4 || this.xmlHttp.readyState == 0 )
{
var oThis = this;
this.xmlHttp.open(metohod, url);
this.xmlHttp.onreadystatechange = function(){ oThis.readyStateChange(); };
this.xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
this.xmlHttp.send(null);
};
};
};
AjaxComm.prototype.abortCallBack = function()
{
if(this.xmlHttp)this.xmlHttp.abort();
};
AjaxComm.prototype.onLoading = function(){}
AjaxComm.prototype.onLoaded = function(){}
AjaxComm.prototype.onInteractive = function(){}
AjaxComm.prototype.onComplete = function(responseText, responseXml){}
AjaxComm.prototype.onAbort = function(){}
AjaxComm.prototype.onError = function(status, statusText){}
AjaxComm.prototype.readyStateChange = function ()
{
if( this.xmlHttp.readyState == 1 )
{
this.onLoading();
};
else if( this.xmlHttp.readyState == 2 )
{
this.onLoaded();
};
else if( this.xmlHttp.readyState == 3 )
{
this.onInteractive();
};
else if( this.xmlHttp.readyState == 4 )
{
if( this.xmlHttp.status == 0 )
this.onAbort();
else if( this.xmlHttp.status == 200 && this.xmlHttp.statusText == "OK" )
this.onComplete(this.xmlHttp.responseText, this.xmlHttp.responseXML);
else
this.onError(this.xmlHttp.status, this.xmlHttp.statusText, this.xmlHttp.responseText);
};
};

