Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.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
Javascript 从路径名获取XML页_Javascript_Xml_Ajax_Parsing_Hyperlink - Fatal编程技术网

Javascript 从路径名获取XML页

Javascript 从路径名获取XML页,javascript,xml,ajax,parsing,hyperlink,Javascript,Xml,Ajax,Parsing,Hyperlink,我在一个使用XML获取数据的站点服务器端工作。我需要的XML的路径类似于“/image/user/username/” 我需要使用以下方法从结果链接获取XML文件 <script type="text/javascript"> imagesByUser('/../image/user/{{ user.username }}/') 我用这个得到文件 xmlHttp.open("GET",url,true); xmlHttp.send() 而且,当我使用像 images

我在一个使用XML获取数据的站点服务器端工作。我需要的XML的路径类似于“/image/user/username/”

我需要使用以下方法从结果链接获取XML文件

 <script type="text/javascript">

imagesByUser('/../image/user/{{ user.username }}/') 
我用这个得到文件

    xmlHttp.open("GET",url,true);
xmlHttp.send()

而且,当我使用像 imagesByUser('images.xml')


那么为什么它不能从服务器上的一页开始工作呢???

从底部阅读您的问题-我被困在
上了,那么为什么它不能从服务器上的一页开始工作呢???

必须为AJAX指定正确的协议才能工作。对于托管服务器上的页面,它必须是
http://
,对于本地文件系统上的文件,它必须是
file:///path/filename

据我所知,要正确使用XMLHttpRequest对象,必须正确使用协议 请参见第页的示例

    xmlHttp.open("GET",url,true);