<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    軟件藝術(shù)思考者  
    混沌,彷徨,立志,蓄勢...
    公告
    日歷
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導(dǎo)航

    隨筆分類(86)

    隨筆檔案(85)

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

     

    樹青兄寫的一個(gè)ajax類。
    var http_request = false;
    function send_request(method,url,formName,responseType,callback) {
    ?http_request = false;
    ?var content =""
    ?if(forName != null)content = getFormAsString(formName);
    ??
    ?if(window.XMLHttpRequest) {
    ??http_request = new XMLHttpRequest();
    ??if (http_request.overrideMimeType) {
    ???http_request.overrideMimeType("text/xml");
    ??}
    ?}
    ?else if (window.ActiveXObject) {
    ??try {
    ???http_request = new ActiveXObject("Msxml2.XMLHTTP");
    ??} catch (e) {
    ???try {
    ????http_request = new ActiveXObject("Microsoft.XMLHTTP");
    ???} catch (e) {}
    ??}
    ?}
    ?if (!http_request) {
    ??window.alert("不能創(chuàng)建XMLHttpRequest對象實(shí)例.");
    ??return false;
    ?}
    ?if(responseType.toLowerCase()=="text") {
    ??http_request.onreadystatechange = callback;
    ?}
    ?else if(responseType.toLowerCase()=="xml") {
    ??http_request.onreadystatechange = callback;
    ?}
    ?else {
    ??window.alert("響應(yīng)類別參數(shù)錯(cuò)誤。");
    ??return false;
    ?}
    ?if(method.toLowerCase()=="get") {
    ??http_request.open(method, url, true);
    ?}
    ?else if(method.toLowerCase()=="post") {
    ??http_request.open(method, url, true);
    ??http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");??
    ?}
    ?else {
    ??window.alert("http請求類別參數(shù)錯(cuò)誤。");
    ??return false;
    ?}??
    ?if(window.ActiveXObject) http_request.setRequestHeader("If-Modified-Since", "0");
    ?http_request.send(content);
    }

    function getFormAsString(formName){

    returnString ="";

    formElements=document.forms[formName].elements;

    for(var i=formElements.length-1;i>=0; --i ){

    returnString+="&"

    +escape(formElements[i].name)+"="

    +escape(formElements[i].value);

    }

    }

    posted on 2006-11-28 15:03 智者無疆 閱讀(303) 評論(4)  編輯  收藏 所屬分類: Client teachnolgy research
    評論:
    • # re: ajax study (1)  self Posted @ 2006-11-28 15:14
      用法:
      send_request("POST","../index.htm","form1","text",changprocess)  回復(fù)  更多評論   

    • # re: ajax study (1)  self Posted @ 2006-12-11 16:19
      改進(jìn)后的。
      var http_request = false;

      function send_request(method,url,formName,responseType,callback) {
      http_request = false;
      var content =""
      content = getFormAsString(formName);

      if(window.XMLHttpRequest) {
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
      http_request.overrideMimeType("text/xml");
      }
      }
      else if (window.ActiveXObject) {
      try {
      http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
      try {
      http_request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
      }
      }
      if (!http_request) {
      window.alert("不能創(chuàng)建XMLHttpRequest對象實(shí)例.");
      return false;
      }
      if(responseType.toLowerCase()=="text") {
      http_request.onreadystatechange = callback;
      }
      else if(responseType.toLowerCase()=="xml") {
      http_request.onreadystatechange = callback;
      }
      else {
      window.alert("響應(yīng)類別參數(shù)錯(cuò)誤。");
      return false;
      }
      if(method.toLowerCase()=="get") {
      http_request.open(method, url, true);
      }
      else if(method.toLowerCase()=="post") {
      http_request.open(method, url, true);
      http_request.setRequestHeader('Content-Type','text/xml; charset=utf-8');
      }
      else {
      window.alert("http請求類別參數(shù)錯(cuò)誤。");
      return false;
      }
      if(window.ActiveXObject) http_request.setRequestHeader("If-Modified-Since", "0");
      http_request.send(content);
      }

      function getFormAsString(formName){

      returnString ="";

      formElements=document.forms[formName].elements;

      for(var i=formElements.length-1;i>=0; --i ){

      returnString+="&"

      +escape(formElements[i].name)+"="

      +escape(formElements[i].value);

      }
      return returnString;
      }   回復(fù)  更多評論   

    • # re: ajax study (1)  self Posted @ 2006-12-11 16:20
      一個(gè)好東西
      // mozXPath [http://km0ti0n.blunted.co.uk/mozxpath/] km0ti0n@gmail.com
      // Code licensed under Creative Commons Attribution-ShareAlike License
      // http://creativecommons.org/licenses/by-sa/2.5/
      if( document.implementation.hasFeature("XPath", "3.0") )
      {
      XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
      {
      if( !xNode ) { xNode = this; }

      var oNSResolver = this.createNSResolver(this.documentElement)
      var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
      var aResult = [];
      for( var i = 0; i < aItems.snapshotLength; i++)
      {
      aResult[i] = aItems.snapshotItem(i);
      }

      return aResult;
      }
      XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
      {
      if( !xNode ) { xNode = this; }

      var xItems = this.selectNodes(cXPathString, xNode);
      if( xItems.length > 0 )
      {
      return xItems[0];
      }
      else
      {
      return null;
      }
      }

      Element.prototype.selectNodes = function(cXPathString)
      {
      if(this.ownerDocument.selectNodes)
      {
      return this.ownerDocument.selectNodes(cXPathString, this);
      }
      else{throw "For XML Elements Only";}
      }

      Element.prototype.selectSingleNode = function(cXPathString)
      {
      if(this.ownerDocument.selectSingleNode)
      {
      return this.ownerDocument.selectSingleNode(cXPathString, this);
      }
      else{throw "For XML Elements Only";}
      }

      }  回復(fù)  更多評論   

    • # re: ajax study (1)  self Posted @ 2006-12-11 16:20
      一個(gè)好東西
      // mozXPath [http://km0ti0n.blunted.co.uk/mozxpath/] km0ti0n@gmail.com
      // Code licensed under Creative Commons Attribution-ShareAlike License
      // http://creativecommons.org/licenses/by-sa/2.5/
      if( document.implementation.hasFeature("XPath", "3.0") )
      {
      XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
      {
      if( !xNode ) { xNode = this; }

      var oNSResolver = this.createNSResolver(this.documentElement)
      var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
      var aResult = [];
      for( var i = 0; i < aItems.snapshotLength; i++)
      {
      aResult[i] = aItems.snapshotItem(i);
      }

      return aResult;
      }
      XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
      {
      if( !xNode ) { xNode = this; }

      var xItems = this.selectNodes(cXPathString, xNode);
      if( xItems.length > 0 )
      {
      return xItems[0];
      }
      else
      {
      return null;
      }
      }

      Element.prototype.selectNodes = function(cXPathString)
      {
      if(this.ownerDocument.selectNodes)
      {
      return this.ownerDocument.selectNodes(cXPathString, this);
      }
      else{throw "For XML Elements Only";}
      }

      Element.prototype.selectSingleNode = function(cXPathString)
      {
      if(this.ownerDocument.selectSingleNode)
      {
      return this.ownerDocument.selectSingleNode(cXPathString, this);
      }
      else{throw "For XML Elements Only";}
      }

      }  回復(fù)  更多評論   

     
    Copyright © 智者無疆 Powered by: 博客園 模板提供:滬江博客


       觀音菩薩贊

    主站蜘蛛池模板: 亚洲天堂视频在线观看| 国产精品亚洲精品日韩电影| 国产乱子伦精品免费女| 99精品免费观看| 黄 色一级 成 人网站免费| 中文字幕乱码亚洲精品一区| 亚洲视频国产精品| 亚洲av之男人的天堂网站| 亚洲国产成人精品无码久久久久久综合 | 亚洲色丰满少妇高潮18p| 亚洲黄色在线电影| 久久精品国产亚洲AV麻豆~| 亚洲国产精品无码久久青草 | 亚洲中文字幕久久精品无码2021| 国产亚洲精品精华液| 亚洲人午夜射精精品日韩| 免费观看一级毛片| 女人被男人桶得好爽免费视频| 性xxxxx免费视频播放| 18禁成人网站免费观看| 美丽姑娘免费观看在线观看中文版 | a级毛片黄免费a级毛片| 成人自慰女黄网站免费大全| 日韩一区二区三区免费播放| 蜜臀亚洲AV无码精品国产午夜.| 亚洲最大的成人网站| 亚洲人成77777在线观看网| 精品久久亚洲中文无码| 亚洲国产精品美女| 亚洲一区二区三区高清视频| 亚洲午夜电影在线观看| 亚洲mv国产精品mv日本mv| 亚洲啪啪免费视频| 波多野结衣亚洲一级| 亚洲熟妇无码一区二区三区| 亚洲精品无码成人片久久不卡| 亚洲精华液一二三产区| 国产精品观看在线亚洲人成网| 边摸边吃奶边做爽免费视频99| 男人和女人高潮免费网站| 久久国产美女免费观看精品|