[code="js"]
var net ={};
net.ContentLoader = function(url,dealBusinessLogic){
this.url=url;
this.dealBusinessLogic=dealBusinessLogic;
loadXMLDoc();
}
net.ContentLoader.prototype={
loadXMLDoc:function(){
this.createReq();
this.setConnect();
this.sendReq();
this.waitAndDeal()
},
createReq:function(){
if(window.XMLHttpRequest)
this.req=new XMLHttpRequest;
if(window.ActiveXObject)
this.req = new ActiveXObject("Microsoft.XMLHTTP");
},
setConnect:function(){
this.req.open=("get",this.url,true);
},
sendReq:function(){
this.req.send(null);
},
waitAndDeal:function(){
var that = this;
this.req.onreadystatechange=function(){
dealDetail.call(that);
}
},
dealDetail=function(){
if(this.req.readyState==4){
if(this.req.status==200){
this.dealBusinessLogic();
}
}
}
}
var obj = new net.ContentLoader("http://localhost/a?name=fire8119",function(){alert(" ")});
[/code]
createReq();
setConnect();
sendReq();
waitAndDeal();
这4个方法被公开了,理想状态应该被隐藏,obj不应该直接获取这4个方法,而只能拥有loadXMLDoc方法。
应该怎么修改?