﻿function xmlHttpClass()
{
    this.xmlHttp=null;
    this.url=null;
    this.sendData=null;  //var SendData = 'id='+obj.value; 
    this.element=null;
    
    this.init=function(url,sendData)
    {
      
       this.sendData=sendData;
       this.url=url+"?"+this.sendData;
       //winow.status=this.sendData;
    }
    
    this.CreateXMLHttpRequest= function()
    {
	    if (window.ActiveXObject)
	    {
		    this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    else
	    {
		    this.xmlHttp = new XMLHttpRequest();
	    }
    }


    this.BeginXMLHttpRequest=function()
    {
       
        this.CreateXMLHttpRequest();
        this.xmlHttp.open("POST",this.url,true);        //采用post方法提交数据
        this.xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        this.xmlHttp.send(this.SendData);  
        this.xmlHttp.onreadystatechange =this.CallBack; //请求状态改变事件触发CallBack功能
    }
    
    this.setCallBack=function(fun)
    {
       this.CallBack=fun;
    }
    
    this.CallBack=function()
    {  
        if(this.xmlHttp.readyState==4)
        {
          if(this.xmlHttp.status==200)
          {   
	        //document.getElementById("ItemLists").innerHTML = xmlHttp.responseText;
	      }
          else
          {
	        //document.getElementById("ItemLists").innerHTML='出错：'+xmlHttp.statusText;
          }
        }
        else
        {
	        //document.getElementById("ItemLists").innerHTML="正在提交数据...";
        }
       
    }

}

//var mm=new xmlHttpClass();
//mm.init("chy","id");
//mm.CallBack();
//function CallBack()
//{
//  alert("other");
//}
//mm.setCallBack(CallBack);
//mm.CallBack();
