﻿// JScript 文件
/*
tansar 
*/

function CallBackObject()
{
	this.XmlHttp=new  this.GetHttpObject();
	
}
CallBackObject.prototype.GetHttpObject=function()
{
	var xmlhttp;
//	if (!xmlhttp && typeof XMLHttpRequest !='undefined')
//	{
		try{xmlhttp=new XMLHttpRequest();}
		catch(e)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
//	}
	return xmlhttp;//������
}
CallBackObject.prototype.DoCallBack=function(URL)
{
        
		if (this.XmlHttp)
		{
		    

                this.XmlHttp.open('get',URL);
                var othis=this;
            
                this.XmlHttp.onreadystatechange=function()
                {
                    othis.ReadyStateChange();
                	 

            }
            this.XmlHttp.send(null);
			
		}
	
}

CallBackObject.prototype.AborkCallBack=function()
{
	if (this.XmlHttp)
	{
		this.XmlHttp.abort();//取消异步操作.
	}
	
}
CallBackObject.prototype.OnLoading=function()
{
	//装入OnLoading...
}
CallBackObject.prototype.OnLoaded=function()
{
	//装入完毕.OnLoaded
	
}
CallBackObject.prototype.OnInteractive=function()
{
	//交互状态.OnInteractive
	
}
CallBackObject.prototype.OnComplete=function(responseText,responseXml)
{
	//完成	
}
CallBackObject.prototype.OnAbort=function()
{
	//Cancel
	
}
CallBackObject.prototype.OnError=function(status,statusText)
{
	//出错 OnError
}
//处理
CallBackObject.prototype.ReadyStateChange=function()
{
		/*
		 * 0表示初始化
		 * 1表示装入
		 * 2表示装入完毕
		 * 3表示正在交互获取数据
		 * 4表示完毕.
		 */
		
	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)
	{
		/*this.XmlHttp.status
		 *0表示取消
		 *200表示完成
		 */
		if (this.XmlHttp.status==0)
		{
			this.OnAbort();
			
		}else if (this.XmlHttp.status==200)
		{
			this.OnComplete(this.XmlHttp.responseText,this.XmlHttp.responseXML);//高用函数
		}else
		
		{
			this.OnError(this.XmlHttp.status,this.XmlHttp.statusText)
		}
	}
	
}