隨筆-7  評論-24  文章-102  trackbacks-0

            function createHttpRequest(){
             var httprequest=false;
             if (window.XMLHttpRequest)
             { // if Mozilla, Safari etc
               httprequest=new XMLHttpRequest();
               if (httprequest.overrideMimeType)
                 httprequest.overrideMimeType('text/xml');
              }
              else if (window.ActiveXObject)
              { // if IE
                try {
                  httprequest=new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e){
                  try{
                     httprequest=new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  catch (e){}
                }
              }
              return httprequest;
           }
           
           
          function createXml(str){
          if(document.all){
           var xmlDom=new ActiveXObject("Microsoft.XMLDOM")
           xmlDom.loadXML(str)
           return xmlDom
          }
          else
           return new DOMParser().parseFromString(str, "text/xml")
          }

           

           

            function showSchedule(sid,f){
             var url = "../schedule.do?operate=toFindById";
             var postStr = "uid=" + encodeURI(sid);
                 
              //IE瀏覽器關(guān)于頻繁傳送數(shù)據(jù)初始化的問題
             httpRequest.open("POST", url, true);
             httpRequest.onreadystatechange = function(){
              if(httpRequest.readyState == 4)
               if(httpRequest.status == 200){
                var xml = createXml(httpRequest.responseText);
                var item = xml.getElementsByTagName("Schedule")[0]; 
                
                var scheduleId = item.getElementsByTagName("scheduleId")[0].firstChild.nodeValue;
                var title = item.getElementsByTagName("title")[0].firstChild.nodeValue;
                var schContent = item.getElementsByTagName("schContent")[0].firstChild.nodeValue;
                var address = item.getElementsByTagName("address")[0].firstChild.nodeValue;
                var ifPrivate = item.getElementsByTagName("ifPrivate")[0].firstChild.nodeValue;
                var createTime = item.getElementsByTagName("createTime")[0].firstChild.nodeValue;
                var beginTime = item.getElementsByTagName("beginTime")[0].firstChild.nodeValue;
                var endTime = item.getElementsByTagName("endTime")[0].firstChild.nodeValue;
                var meetingId = item.getElementsByTagName("meetingId")[0].firstChild.nodeValue;      

                f.scheduleId.value = scheduleId;
                f.title.value = title;
                f.address.value = address;
                f.meetingId.value = meetingId;
                f.schContent.value = schContent;
                if(ifPrivate == 0)
                 f.ifPrivate.checked = true;
                else
                 f.ifPrivate.checked = false;
                
                f.beginTime.value = beginTime;
                f.endTime.value = endTime;  
                f.option.value = "doModify";   
               }
             }
             httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
             httpRequest.send(postStr);
            }



          ====================================

          dom4j-1.6.1.jar

          import org.dom4j.Document;
          import org.dom4j.DocumentHelper;
          import org.dom4j.Element;

              Document doc = DocumentHelper.createDocument();
              Element node = doc.addElement("Depart");
              
              Element departId = node.addElement("departId");
              departId.setText(item.getDepartId().toString());
              Element branchId = node.addElement("branchId");
              branchId.setText(item.getBranchId().toString());
              Element departName = node.addElement("departName");
              departName.setText(item.getDepartName());
              Element principalUserId = node.addElement("principalUserId");
              principalUserId.setText(item.getPrincipalUserId().toString());
              Element connectTelNo = node.addElement("connectTelNo");
              connectTelNo.setText(item.getConnectTelNo());
              Element connectMobileTelNo = node.addElement("connectMobileTelNo");
              connectMobileTelNo.setText(item.getConnectMobileTelNo());
              Element faxes = node.addElement("faxes");
              faxes.setText(item.getFaxes());
              
              PrintWriter out = response.getWriter();
              out.println(doc.asXML());
              out.flush();
              out.close();


          ================================

          request.setContentType("text/xml");

          httpRequest.resoponseXML;

          ===========================
          利用函數(shù)格式化 POST 請求參數(shù)

           function addParam(paramObj, paramName, paramValue){
            if(paramObj.length > 0)
             paramObj += "&";
            return paramObj + encodeURIComponent(paramName)
             + "=" + encodeURIComponent(paramValue);
           }


          =============================================
          javascript 里面的遍歷

          for (pop in windowxxxx){
              .....
          }

          posted on 2009-03-22 09:50 黃小二 閱讀(427) 評論(0)  編輯  收藏 所屬分類: Ajax
          主站蜘蛛池模板: 德阳市| 琼结县| 旬邑县| 河津市| 西充县| 建瓯市| 陇川县| 高淳县| 九寨沟县| 扎囊县| 新余市| 万荣县| 屏南县| 阜康市| 安平县| 崇礼县| 喀什市| 庆元县| 万盛区| 定安县| 泾川县| 安宁市| 毕节市| 新津县| 方城县| 闵行区| 普兰店市| 绥芬河市| 友谊县| 朔州市| 迁安市| 梁平县| 兰溪市| 广南县| 淮安市| 钦州市| 西安市| 新巴尔虎右旗| 都安| 阿鲁科尔沁旗| 恩施市|