1
所以我有一個變量「WOEID」是我正在試圖把在爲「W」的價值 -jQuery的YQL選擇RSS可變
$.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>
什麼不行?你會得到什麼錯誤? – 2011-04-05 16:00:07