<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: 博客園 模板提供:滬江博客


       觀音菩薩贊

    主站蜘蛛池模板: 希望影院高清免费观看视频| 国产无遮挡裸体免费视频在线观看| h在线观看视频免费网站| 亚洲嫩草影院久久精品| 最近中文字幕国语免费完整| 亚洲精品在线播放| 国产92成人精品视频免费 | 亚洲av无码潮喷在线观看 | eeuss影院www天堂免费| 亚洲综合激情另类专区| 老司机精品免费视频| 亚洲产国偷V产偷V自拍色戒| 8x8×在线永久免费视频| 亚洲乱码一二三四区麻豆| AV无码免费永久在线观看| 国产人成亚洲第一网站在线播放| 永久免费bbbbbb视频| 一级毛片a免费播放王色电影 | 风间由美在线亚洲一区| 亚洲中文字幕丝袜制服一区| 国产成人久久AV免费| 亚洲二区在线视频| 亚洲高清国产拍精品青青草原| XXX2高清在线观看免费视频| 亚洲色图校园春色| 18禁成年无码免费网站无遮挡| 国产亚洲蜜芽精品久久| 亚洲精品午夜国产VA久久成人| 亚洲国产天堂久久综合| 国产无限免费观看黄网站| 久久久久亚洲精品日久生情 | 中文字幕精品亚洲无线码一区 | 亚洲经典在线观看| 国产男女性潮高清免费网站 | 亚洲精品在线免费观看视频| 在线观看亚洲免费| 野花香高清视频在线观看免费| 亚洲AV一二三区成人影片| 亚洲午夜久久久影院| 国产片AV片永久免费观看| 中文字幕第一页亚洲|