net.xmlHttp.prototype.loadXMLDoc=function(url, params, method, contentType){ if (!method){ method="GET"; } if (!contentType && method=="POST"){ contentType='application/x-www-form-urlencoded'; } if (window.XmlHttpRequest){ this.req=new XmlHttpRequest(); } else if (window.ActiveXObject){ this.req=new ActiveXObject("Microsoft.xmlHttp"); } if (this.req){ try{ var loader=this; this.req.onreadystatechange=function(){ net.xmlHttp.onReadyState.call(loader); } this.req.open(method,url,true); if (contentType){ this.req.setRequestHeader('Content-Type', contentType); } this.req.send(params); }catch (err){ this.onerror.call(this); } } }
net.xmlHttp.onReadyState=function(){ var req=this.req; var ready=req.readyState; if (ready==net.READY_STATE_COMPLETE){ var httpStatus=req.status; if (httpStatus==200 httpStatus==0){ this.onload.call(this); }else{ this.onerror.call(this); } } }
/**//* Post begin*/ //绑定Post发送xmlHttp事件到btnTestPost function loadTestPost() { var iobj = document.getElementById("btnTestPost"); //btnTestPost按钮监听的绑定 var clickRouter=new jsEvent.EventRouter(iobj,"onclick"); clickRouter.addListener(btnTestPostClick);