0
我正在嘗試使用YQL從雅虎提取天氣。然而由於某些原因沒有返回,但是我已經嘗試手動調用與Select語句的URL是否它返回我想要的結果。有人可以幫助調試我的代碼出錯了嗎?使用jQuery和YQL提取雅虎天氣
$(function(){
var loc1 = 'Singapore, Singapore'; // Singapore
var u = 'c';
var query1 = "SELECT * FROM weather.forecast WHERE woeid in (select woeid from geo.places(1) where text='" + loc1 + "' AND u='" + u + "'";
var cacheBuster = Math.floor((new Date().getTime())/3600/1000);
var url1 = 'https://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query1) + '&format=json&_nocache=' + cacheBuster;
window['wxCallback1'] = function(data) {
var info = data.query.results.channel;
$('#wxIcon1').append('<img src="weathericon/' + info.item.condition.code + '.gif" width="52" height="52" title="' + info.item.condition.text + '" /><br>' + info.item.condition.text + '<br>');
$('#wxTemp1').html(info.item.forecast[0].low + '<font style="FONT-WEIGHT:normal; FONT-SIZE:12px">°' + (u.toUpperCase()) + '</font>' + ' - ' + info.item.forecast[0].high + '<font style="FONT-WEIGHT:normal; FONT-SIZE:12px">°' + (u.toUpperCase()) + '</font>');
$('#wxHum1').html(info.atmosphere.humidity + '<font style="FONT-WEIGHT:normal; FONT-SIZE:12px">%</font>');
};
$.ajax({
url: url1,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'wxCallback1'
});
});