欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

AJAX請(qǐng)求類

 更新時(shí)間:2006年08月15日 00:00:00   作者:  
復(fù)制代碼 代碼如下:

// 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請(qǐng)求類
by HotHeart(熱血心腸)
Site: http://www.xujiwei.cn/
Blog: http://www.xujiwei.cn/blog/


類名:AJAX

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

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

方法:send()     -  發(fā)送請(qǐng)求,無(wú)參數(shù)


一個(gè)例子:
<script type="text/javascript" src="ajaxrequest.js"></script>
<script type="text/javascript">
var ajaxobj=new AJAXRequest;    // 創(chuàng)建AJAX對(duì)象
ajaxobj.method="GET";   // 設(shè)置請(qǐng)求方式為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ā)送請(qǐng)求
</script>

相關(guān)文章

最新評(píng)論