Javascript 从路径名获取XML页
我在一个使用XML获取数据的站点服务器端工作。我需要的XML的路径类似于“/image/user/username/” 我需要使用以下方法从结果链接获取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
<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);