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); } } }
net.xmlHttp.prototype.defaultError=function(){ alert("error fetching data!" +"\n\nreadyState:"+this.req.readyState +"\nstatus: "+this.req.status +"\nheaders: "+this.req.getAllResponseHeaders()); } 下面开始写发送xmlHttp请求的代码: default.js //全局xmlHttp对象 var cobj; /**//* Post begin*/ //绑定Post发送xmlHttp事件到btnTestPost function loadTestPost() { var iobj = document.getElementById("btnTestPost"); //btnTestPost按钮监听的绑定 var clickRouter=new jsEvent.EventRouter(iobj,"onclick"); clickRouter.addListener(btnTestPostClick); } function btnTestPostClick() { // open参数 url, onload, params, method, contentType, onerror cobj = new net.xmlHttp("DefaultHandler.ashx",dealResult, "<T/>", "POST"); } /**//* Post end*/ /**//* Get begin*/ //绑定Get发送xmlHttp事件到btnTestGet function loadTestGet() { var iobj = document.getElementById("btnTestGet"); //btnTestGet按钮监听的绑定 var clickRouter=new jsEvent.EventRouter(iobj,"onclick"); clickRouter.addListener(btnTestGetClick); } function btnTestGetClick() { // open参数 url, onload, params, method, contentType, onerror cobj = new net.xmlHttp("DefaultHandler.ashx?T=1",dealResult, null, "GET"); } /**//* Get end*/
|