未捕获的TypeError:对象#<document>没有方法'load'</document>

时间:2013-04-03 12:05:20

标签: javascript

伙计们,我在使用javascript阅读xml文件时遇到问题,PLZ帮帮我
这是我的代码:

<html>
<body>
<script type="text/javascript">
var xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("myfile.xml");
</script>
</body>
</html>

即时通讯使用win7,我使用了Opera 12,最新的chorme,firefox 14,IE9,safari 5(windows verison),并且它们都没有用,而google chorme给了我这个

Uncaught TypeError: Object #<Document> has no method 'load' 

我不知道这里有什么不对,提前

1 个答案:

答案 0 :(得分:0)

  

伙计们,我在使用javascript阅读xml文件时遇到了麻烦

使用javascript动态加载xml文件的大量google结果(参见AJAX)。但为了帮助您开始正确的方向,请考虑

// Caveat: IE 5 and IE 6 must do:
// var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","myfile.xml",false);  // the third param sets async=false
xmlhttp.send();
var xmldata = xmlhttp.responseXML;

编辑:以上内容来自我的AJAX备注,请参阅the w3 tutorial有关演练版的主题。

相关问题