JavaScript能否从第三方域加载XML数据? [英] Can JavaScript load XML data from a third-party domain?
问题描述
JavaScript可以从 Yahoo 载入RSS XML资讯提供吗?
Can JavaScript load an RSS XML feed from Yahoo?
客户端JS是否允许访问第三方域?
Is client-side JS allowed to access 3rd-party domains?
推荐答案
技术在我的博客帖子中概述了 Yahoo的不成熟指南Query Langauge
You can use the technique outlined in my blog post Unwritten guide to Yahoo Query Langauge
您将使用如下所示的yql语法查询XML数据表:
You would query the XML data table with a yql statment like this:
select * from xml
where url="http://path/to/xml
然后, (可以使用document.createElement('script'))与一个src http://query.yahooapis.com/v1/public/yql?q={your这里}&format = json&callback = {您的函数here}其中{your yql here}替换为您的yql编码的URI编码版本。
Then you would add a script tag to your html (can be done with document.createElement('script')) with a src http://query.yahooapis.com/v1/public/yql?q={your yql here}&format=json&callback={your function here} where {your yql here} is replace with a URI Encoded version of you yql statment.
这篇关于JavaScript能否从第三方域加载XML数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!