最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AJAX請求類

 更新時間:2006年08月15日 00:00:00   作者:  
復制代碼 代碼如下:

// AJAX類
function AJAXRequest() {
 var xmlObj = false;
 var CBfunc,ObjSelf;
 ObjSelf=this;
 try { xmlObj=new XMLHttpRequest; }
 catch(e) {
  try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
  catch(e2) {
   try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
   catch(e3) { xmlObj=false; }
  }
 }
 if (!xmlObj) return false;
 this.method="POST";
 this.url;
 this.async=true;
 this.content="";
 this.callback=function(cbobj) {return;}
 this.send=function() {
  if(!this.method||!this.url||!this.async) return false;
  xmlObj.open (this.method, this.url, this.async);
  if(this.method=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlObj.onreadystatechange=function() {
   if(xmlObj.readyState==4) {
    if(xmlObj.status==200) {
     ObjSelf.callback(xmlObj);
    }
   }
  }
  if(this.method=="POST") xmlObj.send(this.content);
  else xmlObj.send(null);
 }
}


AJAX請求類
by HotHeart(熱血心腸)
Site: http://www.xujiwei.cn/
Blog: http://www.xujiwei.cn/blog/


類名:AJAX

創(chuàng)建方法:var ajaxobj=new AJAX;,如果創(chuàng)建失敗則返回false

屬性:method  -  請求方法,字符串,POST或者GET,默認為POST
   url         -  請求URL,字符串,默認為空
   async     -  是否異步,true為異步,false為同步,默認為true
   content -  請求的內(nèi)容,如果請求方法為POST需要設(shè)定此屬性,默認為空
   callback  - 回調(diào)函數(shù),即返回響應(yīng)內(nèi)容時調(diào)用的函數(shù),默認為直接返回,回調(diào)函數(shù)有一個參數(shù)為XMLHttpRequest對象,即定義回調(diào)函數(shù)時要這樣:function mycallback(xmlobj)

方法:send()     -  發(fā)送請求,無參數(shù)


一個例子:
<script type="text/javascript" src="ajaxrequest.js"></script>
<script type="text/javascript">
var ajaxobj=new AJAXRequest;    // 創(chuàng)建AJAX對象
ajaxobj.method="GET";   // 設(shè)置請求方式為GET
ajaxobj.url="default.asp"  // URL為default.asp
// 設(shè)置回調(diào)函數(shù),輸出響應(yīng)內(nèi)容
ajaxobj.callback=function(xmlobj) {
     document.write(xmlobj.responseText);
}
ajaxobj.send();    // 發(fā)送請求
</script>

相關(guān)文章

最新評論

耒阳市| 桂东县| 龙井市| 南雄市| 沁源县| 太谷县| 无锡市| 安泽县| 台南县| 曲阳县| 永宁县| 双鸭山市| 平原县| 东明县| 颍上县| 龙泉市| 铁岭县| 墨江| 上饶县| 南投县| 永泰县| 盈江县| 太仆寺旗| 富民县| 县级市| 黑水县| 襄垣县| 修水县| 平乡县| 临沂市| 顺平县| 泉州市| 南乐县| 渝北区| 阿克陶县| 丘北县| 海阳市| 中江县| 改则县| 密云县| 黄石市|