未捕获类型错误:Object #<Document>没有方法'load'
Uncaught TypeError: Object #<Document> has no method 'load'
伙计们,我有麻烦阅读XML文件使用javascript,请帮助我
下面是我的代码:
<html>
<body>
<script type="text/javascript">
var xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("myfile.xml");
</script>
</body>
</html>
我用的是win7,我用过opera 12,最新的chrome, firefox 14,IE9,safari 5(windows版本),它们都不行,而google chrome给了我这个
Uncaught TypeError: Object #<Document> has no method 'load'
我不知道哪里不对,提前谢谢
伙计们,我有麻烦读取XML文件使用javascript
大量的谷歌结果加载xml文件动态使用javascript (cf. 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笔记,请参阅关于该主题的w3教程以获得演练版本。