JavaScript能否从第三方域加载XML数据? [英] Can JavaScript load XML data from a third-party domain?

查看:142
本文介绍了JavaScript能否从第三方域加载XML数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆