﻿// JScript 文件
function GdpxAjaxObject(){
	this.XmlHttp = this.GetHttpObject();
}
GdpxAjaxObject.prototype.GetHttpObject = function()
{
	var xmlhttp;
	try{
		 xmlhttp=new XMLHttpRequest();
	}catch(e){
		 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}
GdpxAjaxObject.prototype.DoCallBack =  function(URL,PostValue)
{
	if ( this.XmlHttp)
	{
		if ( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
		{
			var oThis = this;
			this.XmlHttp.open('POST',URL);
			this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange(); };
			this.XmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			this.XmlHttp.send(PostValue);
		}
	}
}
GdpxAjaxObject.prototype.AbortCallBack = function()
{
	if( this.XmlHttp )
	this.XmlHttp.abort();
}
GdpxAjaxObject.prototype.OnLoading = function()
{
	//Loading
}
GdpxAjaxObject.prototype.OnLoaded = function()
{
	//Loaded
}
GdpxAjaxObject.prototype.OnInteractive = function()
{
	//Interactive
}
GdpxAjaxObject.prototype.OnComplete = function(responseText,responseXml)
{
	//Complete	
}
GdpxAjaxObject.prototype.OnAbort = function()
{
	//Abort
}
GdpxAjaxObject.prototype.OnError = function(status,statusText)
{
	//Error
}
GdpxAjaxObject.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);
	}
}

