我有2种不同的YQL语句,其中一种有效而另一种无效,我找不到问题所在...我对此逐渐失去了主意:/
这是代码(它是内部轮播)
<div class="carousel-item">
<div class="whitetext">
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script>
<script type='text/javascript'>
function top_stories(o){
var items = o.query.results.item;
var output = '';
var no_items=items.length;
for(var i=0;i<3;i++){
var title = items[i].title;
var link = items[i].link;
var desc = items[i].description;
output += "<h3><a href='" + link + "'>"+title+"</a></h3>" + desc + "<hr/>";
}
document.getElementById('results').innerHTML = output;
}
</script>
<div id='results'></div>
<script src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22http%3A%2F%2Frss.news.yahoo.com%2Frss%2Ftopstories%22&format=json&callback=top_stories'>
<!-- END OF PAGE 2 HERE -->
</script>
</div>
<div class="carousel-item">
<div class="whitetext">
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script>
<script type='text/javascript'>
function top_nyheter(o){
var items = o.query.results.item;
var output = '';
var no_items=items.length;
for(var i=0;i<no_items;i++){
document.write("I loopen nu.");
var title = items[i].title;
var link = items[i].link;
var desc = items[i].description;
output += "<h3><a href='" + link + "'>"+title+"</a></h3>" + desc + "<hr/>";
}
// Place news stories in div tag
document.getElementById('resultsnews').innerHTML = output;
}
</script>
<div id='resultsnews'></div>
<script src='https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%20%3Dhttps%3A%2F%2Fwww.svt.se%2Fnyheter%2Frss.xml&format=json&callback=top_nyheter'></script>
<!-- END OF PAGE 3 HERE -->
</script>
第一个YQL调用工作正常,返回的json看起来很好,结构也很好,但是为什么我不能访问第二个调用?
此https://query.yahooapis.com/v1/public/yql?q=select%20 *%20from%20rss%20where%20url%3D%27https%3A%2F%2Fwww.svt.se%2Fnyheter%2Frss.xml%27&format = json&env = store%3A%2F%2Fdatatables粘贴到我的浏览器中的.org%2Falltableswithkeys完全返回我的期望。
https://developer.yahoo.com/yql/让我测试查询,这是:从rss中选择*,其中url ='https://www.svt.se/nyheter/rss.xml'拥有我想要的数据。现在,为什么我不能在脚本中访问它?我什至无法访问返回的内容以检查错误消息。
任何对错误的帮助/想法将不胜感激!