﻿function MiniAjax(url,Objcontainer)
{
    this.up_xhttp=null;
    this.up_url=url;
    this.result_container=Objcontainer;
}

MiniAjax.prototype.LoadPage=function()
{
    if (typeof(XMLHttpRequest) != 'undefined')
		this.up_xhttp = new XMLHttpRequest();
	else if (typeof(ActiveXObject) != 'undefined')
		this.up_xhttp = new ActiveXObject('Microsoft.XMLHTTP');
	else
	{
	    alert("创建XMLHttpRequest组件失败！");
	    return;
	}
	
    
    var _this=this;
    window.setTimeout(function(){_this.DoLoadPage()},100);
}


MiniAjax.prototype.DoLoadPage=function()
{
    var _this=this;
    this.up_xhttp.onreadystatechange =function()
    {
        _this.OnProgressResult();
    }
	this.up_xhttp.open('GET', this.up_url, false);
	this.up_xhttp.send('');
	
	/**
	 * Firefox <= 2.0.0 doesn't fire onreadystatechange for synchronous requests.
	 * See http://lukav.com/wordpress/2007/04/12/firefox-firebug-and-synchronos-calls-problem/
	 */
	var isGecko = (document.addEventListener) ? true : false;
	try {
		if (isGecko && this.up_xhttp.onreadystatechange == null) {
		    var msg=this.up_xhttp.responseText;
		    OnPageLoadOk(this.result_container,msg);			
		}
	}
	catch (e) { alert(e); }
};

MiniAjax.prototype.OnProgressResult=function()
{
    if (this.up_xhttp.readyState == 4)
    {    
        if (this.up_xhttp.status == 200)
        {           
            OnPageLoadOk(this.result_container,this.up_xhttp.responseText);
        }
        else
        {            
            this.result_container.innerHTML='发生错误：'+this.up_xhttp.status;
        }
    }
};

