Bryan

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            37 Posts :: 3 Stories :: 24 Comments :: 0 Trackbacks

          // AJAXLib v. 1.0
          // author: Jacek Karaszewski, http://www.karaszewski.com/tools/ajaxlib/
          // licenced under Creative Commons Attribution 2.5 License

          // public

          // function loadXMLDoc(xml_url, function_name, ignore_white)
          function loadXMLDoc(url, callFunc, ignoreWhite) {
           functionToCall = callFunc;
           stripWS = ignoreWhite;
           xmlRequestObj = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")
           xmlRequestObj.onreadystatechange = proccessXML;
           xmlRequestObj.open("GET", url, true);
           xmlRequestObj.send(null);
          }


          // private

          function is_ws(nod) {
           return !(/[^\t\n\r ]/.test(nod.data));
          }

          function findWhiteSpace(node, nodeNo) {
           for (i=0; i<node.childNodes.length; i++) {
            if (node.childNodes[i].nodeType == 3 && is_ws(node.childNodes[i])) {
             nodesToDelete[nodesToDelete.length] = node.childNodes[i]
            }
            if (node.childNodes[i].hasChildNodes()) {
             findWhiteSpace(node.childNodes[i], i);
            }
           }
           node = node.parentNode;
           i = nodeNo;
          }

          function stripWhiteSpace(node) {
           nodesToDelete = Array();
           findWhiteSpace(node, 0);
           for(i=nodesToDelete.length-1;i>=0;i--) {
            nodeRef = nodesToDelete[i];
            nodeRef.parentNode.removeChild(nodeRef)
           }
          }

          function proccessXML() {
           if (xmlRequestObj.readyState == 4 && (xmlRequestObj.status == 200 || xmlRequestObj.status == 304)) {
            if(stripWS) {
             stripWhiteSpace(xmlRequestObj.responseXML);
            }
            resultXML = xmlRequestObj.responseXML;
            functionToCall()
           }
          }

          posted on 2008-11-08 21:21 Life is no respector of any genius. 閱讀(377) 評論(0)  編輯  收藏 所屬分類: Ajax

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 佛冈县| 康平县| 永兴县| 珲春市| 定州市| 行唐县| 丰镇市| 栾川县| 新源县| 侯马市| 高要市| 托克逊县| 南平市| 丹寨县| 印江| 汉沽区| 安阳市| 电白县| 丹凤县| 宁南县| 平南县| 九江县| 东辽县| 西宁市| 那坡县| 辽中县| 明溪县| 台安县| 右玉县| 江津市| 明光市| 琼结县| 休宁县| 永平县| 湖南省| 会理县| 那曲县| 博客| 宣城市| 黄冈市| 筠连县|