【发布时间】:2011-07-30 02:45:08
【问题描述】:
所以我有一个变量“woeid”,我正在尝试将其放入“w”的值 -
$.YQL("select * from rss where url='http://weather.yahooapis.com/forecastrss?w="+woeid"'",function(data){
为什么它不起作用?
编辑:整个脚本 -
<script>
$(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=" + woeid,function(data){
var w=data.query.results.item;
var class=w.condition.text;
var encodedclass = class.replace(/\s+/g, '-').toLowerCase();
$('body').addClass(encodedclass);
$('#weatherTemp').html(w.condition.temp+"°");
$('#weatherText').html(w.condition.text+"");
$('#geolat').html(w.title+"");
$('#var').html(lat+"latitude");
});
});
</script>
【问题讨论】:
-
什么不起作用?你得到什么错误?
标签: jquery variables rss quotes yql