XMLHttpRequestオブジェクトの単純パッケージ



	var Class = {
	 create: function() {
	  return function() {
	   this.initialize.apply(this, arguments);
	  };
	 }
	};
	var myXMLHttpRequest = Class.create();
	myXMLHttpRequest.prototype = {
		url : null,
		myRequest : null,
		callBack : null,
	 	initialize : function (urltp,callBack) {
			this.url = urltp;
			this.myRequest = false;
			this.callBack = callBack;
			if(!this.myRequest){
				try{
					//IE6.0 
	    			this.myRequest = new ActiveXObject("Msxml2.XMLHTTP");
	    			if(!this.myRequest){
	    				// IE
	      	 			this.myRequest = new ActionXObject("Microsof.XMLHTTP");
	   	  			}
	   			}
	   			catch(e){
	   				// IE 
	       			this.myRequest = new XMLHttpRequest();
	   			}
			}
		},
		callSever : function (){
			if(this.myRequest){      
			    this.myRequest.open("GET",this.url,true);    
			    this.myRequest.onreadystatechange = this.callBack;
			    this.myRequest.send(null);
			}
		}
	};
	
	var test = new myXMLHttpRequest('data.jsp',callBack);
	function callBack (){
			// 
		    if(test.myRequest.readyState==4) {
		        var response = test.myRequest.responseText;
		        alert(response);
		    }
	}