JavaScript可以从第三方域加载XML数据吗?

Rob*_*cks 5 javascript rss cross-domain

JavaScript可以从Yahoo加载RSS XML Feed 吗?

客户端JS是否允许访问第三方域?

小智 2

您可以使用我的博客文章《雅虎查询语言不成文指南》中概述的技术

您可以使用如下所示的 yql 语句查询 XML 数据表:

select * from xml
  where url="http://path/to/xml
Run Code Online (Sandbox Code Playgroud) 然后,您可以使用 src http://query.yahooapis.com/v1/public/yql?q={your yql here} 在 html 中添加一个 script 标记(可以使用 document.createElement('script') 完成) &format=json&callback={your function here} 其中 {your yql here} 替换为 yql 语句的 URI 编码版本。