| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1248 人关注过本帖
标题:ajax处理XML格式时响应xhr.responseXML为根目录,但其的子对像firstChild为N ...
只看楼主 加入收藏
wangxianping
Rank: 2
等 级:论坛游民
帖 子:13
专家分:22
注 册:2011-9-8
结帖率:0
收藏
已结贴  问题点数:0 回复次数:3 
ajax处理XML格式时响应xhr.responseXML为根目录,但其的子对像firstChild为NULL
<html>
  <head>
    <meta http-equiv="content-type" keywords="ajax" description="ajax 描述" content="text/html;charset=UTF-8">
    <title>ajax的树结构</title>
   
  </head>
  <script language="JavaScript">
      var xhr=false;
    function request(){
         createXMLHttpRequest();
          xhr.open("post","F:\\ASP\\jaxTree.xml",true);
          xhr.onreadystatechange=callBack;
          xhr.send(null);
         
        
   }
     function createXMLHttpRequest(){
            if(window.ActiveXObject){
  xhr=new ActiveXObject('Microsoft.XMLHTTP');
            
     }else if(window.XMLHttpRequest){
         xhr=new XMLHttpRequest();
    }
         
   }
    var callBack=function (){
       if(xhr.readyState==4){
         if(xhr.status==0){
      createTree(xhr.responseXML);
          xmlDoc=xhr.responseXML;
          alert(xmlDoc.documentElement);
           alert(xmlDoc.firstChild);
          }   
      }
    }

   var createTree=function (xmlDoc){
      
      alert(xmlDoc.hasChildNodes);
   

}
  </script>
  <body onload="request();">
     <div id='tree' style='float:left;width:300'>xml格式</div>
     <div id="message" style="float:right;width:500">文本</div>
  </body>
</html>

//jaxTree.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
   <type>
      <computer>硬件组装 </computer>
      <soft>C#编程</soft>   
   </type>
   <type>
      <computer>硬件维护</computer>
      <soft>JavaScript编程</soft>
   </type>
   <type>
      <computer>硬件知识</computer>
      <soft>java编程</soft>
   </type>   
</books>
  

 
搜索更多相关主题的帖子: ajax html function request content 
2011-09-18 17:28
wangxianping
Rank: 2
等 级:论坛游民
帖 子:13
专家分:22
注 册:2011-9-8
收藏
得分:0 
xmlDoc.load("F:\\ASP\\jaxTree.xml");
2011-09-18 23:02
刘杰明
Rank: 8Rank: 8
来 自:山东大学威海校区
等 级:蝙蝠侠
帖 子:155
专家分:872
注 册:2011-6-20
收藏
得分:10 
厉害....

______________________________加油__!__!___!
2011-09-20 08:29
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:10 
...应该没有权限读取吧。。。
2011-09-24 15:35
快速回复:ajax处理XML格式时响应xhr.responseXML为根目录,但其的子对像firstChi ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014757 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved