以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  ajax问题求助  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=24840)


--  作者:testxml
--  发布时间:11/30/2005 1:48:00 PM

--  ajax问题求助
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript">
<!--
var http_request = false;
function reqReady(file)
{
  if(window.xmlHttpRequest) {//Mozia..
    var http_request = new xmlHttpRequest();
 if(http_request.overrideMimeType)
    http_request.overrideMimeType = 'text/xml';
  } else if(window.ActiveXObject)
         {
           try{
          http_request = new window.ActiveXObject("Msxml2.XMLHTTP");
      }catch(e){
         try{
          http_request = new window.ActiveXObject("Microsoft.XMLHTTP");
      }catch(e) {}
   }
  if (!http_request) {
                    alert('Giving up :( Cannot create an XMLHTTP instance');
                    return false;
                }

     http_request.onreadystatechange = function() {
     if(http_request.readyState == 4)

 [color=#FF0000]alert(http_request.responseXML.getElementsByTagName('data')[0].firstChild.data);[/color] }
http_request.open('GET',file,true);
http_request.send(null);
}
}
//-->
</script>
</HEAD>

<BODY>
<span onclick="reqReady('data.xml')">view xml </span>
</BODY>
</HTML>
================
data.xml

<?xml version="1.0" encoding="UTF-8"?>
<root>
<data>
This is some sample data. It is stored in an XML file and retrieved by JavaScript.
</data>
</root>
为什么红色部分老是报错,说没有对象呢?


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
5,378.906ms