//by lingll ( lingll_xl@163.com //use encodeURIComponent to format sData function sendRequest(sUrl,sData,fFnc,sUseGet,bAsync){ if(sUseGet==null)sUseGet=true; if(bAsync==null)bAsync=true; var xmlHttpReq=CreateHttpReq(); if(xmlHttpReq) { xmlHttpReq.onreadystatechange=function() { if(xmlHttpReq.readyState==4) if(xmlHttpReq.status==200) fFnc(xmlHttpReq.responseText); } if(sUseGet){ xmlHttpReq.open("GET",sUrl+"?"+sData,bAsync); xmlHttpReq.send(null); } else{ xmlHttpReq.open("POST",sUrl,bAsync); xmlHttpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlHttpReq.send(sData); } return true; } else return false; } function CreateHttpReq(){ if (window.XMLHttpRequest) return new XMLHttpRequest(); else if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); else return null; |
ajax
最新推荐文章于 2022-06-19 13:50:53 发布