Tag: yql

jQuery美元符号未定义

在我获取历史信息的过程中,我尝试使用以下代码。 Chrome调试器表示Uncaught ReferenceError: $ is not defined 。 你能建议修复,我真的被卡住了。 我只需要在Chrome上工作,我正在使用YQL和Yahoo API。 这里是jsFiddle http://jsfiddle.net/pCK5q/1/ google.load(‘visualization’, ‘1’, {‘packages’:[‘annotatedtimeline’]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); /* historical data code that breaks */ var url = ‘http://query.yahooapis.com/v1/public/yql’; var startDate = ‘2012-01-01’; var endDate = ‘2012-01-08’; var jsonData = encodeURIComponent(‘select * from yahoo.finance.historicaldata where symbol in (“YHOO”,”AAPL”,”GOOG”,”MSFT”) […]

jQuery YQL SELECT FROM rss变量

所以我有一个变量“woeid”,我正试图为“w”的价值投入 – $.YQL(“select * from rss where url=’http://weather.yahooapis.com/forecastrss?w=”+woeid”‘”,function(data){ 为什么它不起作用? 编辑:整个脚本 – $(document).ready(function() { $.YQL = function(query, callback) { var encodedQuery = encodeURIComponent(query.toLowerCase()), url = ‘http://query.yahooapis.com/v1/public/yql?q=’ + encodedQuery + ‘&format=json&callback=?’; $.getJSON(url, callback); }; $.YQL(“select place.woeid from flickr.places where lat=34.45 and lon=-118.54”, function(data) { var w=data.query.results.places.place; woeid = w.woeid }); $.YQL(“select * from rss where url=’http://weather.yahooapis.com/forecastrss?w=” + […]

如何简单地显示YQL的xml输出或将JSON输出显示为html

所以我一直在努力从页面中抓取数据并显示它(与源的格式大致相同)。 我发现YQL,我发现它很棒,除了我无法弄清楚如何只显示整个输出没有什么特别的(基本格式除外) YQL输入代码是: select * from html where url=”http://directory.vancouver.wsu.edu/anthropology” and xpath=”//div[@id=’facdir’]” 使用它返回JSON: http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fdirectory.vancouver.wsu.edu%2Fanthropology%22%20and%20xpath%3D%22%2F%2Fdiv%5B%40id%3D’facdir’%5D%22&format=json&callback=anthropology 我已经按照雅虎教程,创建了新闻小部件等,但没有一个教程涵盖基本视图(也不需要链接,只是段落设置)。 像这样: Name Title Phone:(###)###-#### Location: Building and Room # email@vancouver.wsu.edu 这是我从http://christianheilmann.com输出的内容,但它没有做任何事情(显然她的教程都没有工作,每个人都尝试过): Copied: function anthropology (0) { // get the DIV with the ID $ var info = document.getElementById(‘facdir’); // add a class for styling info.className = ‘js’; // if it exists […]

使用YQL与JQuery进行跨域请求

所以我需要做一个跨域请求,其中响应不是JSON格式的,所以我不能使用.getJSON。 .get显然不起作用,因为它是一个跨域请求。 当我在使用Google搜索时,我遇到了这个( 阅读本文 ),它似乎应该适用于我想要做的事情(这是一个跨域调用,不是使用jquery插件进行json格式化)。 我的代码如下所示。 我知道url工作正常,因为如果我将它粘贴到我的浏览器中,我可以看到响应,根据last.fm文档 服务器响应的主体由一系列\ n(ASCII 10)终止行组成。 典型的成功服务器响应将是这样的: OK 17E61E13454CDD8B68E8D7DEEEDF6170 http://post.audioscrobbler.com:80/np_1.2 http://post2.audioscrobbler.com:80/protocol_1.2 所以我知道我的url很好。 现在我想知道我是如何得到这些信息的,以及为什么我的版本的例子不起作用。 function performHandshake(sk, token, ts){ var token = md5(apiSecret + ts); var urlToUse = “http://post.audioscrobbler.com/?hs=true&p=1.2.1&c=tst&v=1.0&u=chamals&t=” + ts + “&a=” + token + “&api_key=” + apiKey + “&sk=” + sk + “&format=xml&callback=cbfunc”; $(‘#container’).load(urlToUse); $.ajax({ url: urlToUse, type: ‘GET’, success: function(res){ […]

有人可以帮我使用livestream的api来制作跨域xml请求吗?

我正在尝试使用http://www.livestream.com/userguide/?title=Mobile_API#Requesting_a_mobile_stream上的livestream非常有用的移动API来发出xml请求。 我感兴趣的是isLive响应值。 我试图使用像这样的ajax请求 $.ajax({ type: “GET”, url: “http://xproshowcasex.channel-api.livestream-api.com/2.0/getstream”, datatype: “xml”, success: function(xml){ //this is where I need help. This is what I would like to happen if (isLive == true) { //perform action } else { //perform other action } 我正在使用http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/上的插件来制作跨域xml请求。 谁能告诉我这是否是实现这一目标的最有效方法? 我无法让它发挥作用。 当我运行console.log(xml)(可能不对)时,JS控制台显示了objectObject,我认为这意味着我需要解析数据? 如果有人能花点时间解释一下,我会很高兴。 非常感谢。

Yahoo YQL RSS – 错误请求

为了使用jQuery创建跨域AJAX请求,我正在尝试使用YQL RSS。 select * from rss where url=’https://www.top1000funds.com/feed/most-popular-posts/’ 我的代码: var feed = “https://www.top1000funds.com/feed/most-popular-posts/”; var yql = “https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22″+encodeURIComponent(feed)+”%22&format=json&diagnostics=true&callback=&rnd=_”+event.timeStamp; console.log(yql); $.getJSON(yql, function(res) { var html = ”; if(res.query && res.query.results && res.query.results.item){ //code goes here } else { html += ‘The feed is currently not available due to server issues. Check back soon!’; } html += ”; […]

每隔30秒jQuery Ajax请求

我有这段代码,但是当某人在我的网站上时,这些值可能会发生变化。 我需要每隔30秒左右更新一次#finance div。 可以这样做吗? $(function() { $.getJSON( “http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22%5EFTSE%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=?”, function(json){ $(‘#finance’).text(json.query.results.quote.Change); // Patching payload into page element ID = “dog” }); });