Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XML HttpRequest对象_Xml_Html - Fatal编程技术网

XML HttpRequest对象

XML HttpRequest对象,xml,html,Xml,Html,这将读取一个名为“cd_catalog.xml”的文件 它不起作用 例如: <script> xmlhttp.open("GET","http://www.w3schools.com/xml/cd_catalog.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; ... </script> open(“GET”http://www.w3schools.com/xml/cd_catalog.xml“,假);

这将读取一个名为“cd_catalog.xml”的文件

它不起作用

例如:

<script>
xmlhttp.open("GET","http://www.w3schools.com/xml/cd_catalog.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
...
</script>

open(“GET”http://www.w3schools.com/xml/cd_catalog.xml“,假);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
...

什么是获取XML文件URL的正确方法,该文件与服务器上本地存储的XML文件(如“cd_catalog.XML”)的结果相同?请确保您对请求使用相同的协议。我的意思是,我不知道您使用的是http还是https。我的意思是,您用于继续测试的协议,它在broswer的地址栏中显示的一个。是否存在任何控制台错误?出现此错误:
XMLHttpRequest无法加载http://www.w3schools.com/xml/cd_catalog.xml. 请求的资源上不存在“Access Control Allow Origin”标头。起源'http://ontomatica.com因此,不允许访问。
http://www.w3schools.com/xml/cd_catalog.xml
<script>
xmlhttp.open("GET","http://www.w3schools.com/xml/cd_catalog.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
...
</script>