0
我正在使用Yahoo Weather API。无法获取未定义或空引用的属性“查询”
这里是我的代码:
<script>
var callbackFunction = function (data) {
console.log(data);
var location = data.query.results.channel.location;
var condition = data.query.results.channel.item.condition;
var wind = data.query.results.channel.wind;
var units = data.query.results.channel.units;
document.getElementById('Weather-Info').innerHTML = 'The weather for ' + location.city + ', ' + location.region + ' is ' + condition.temp + units.temperature + ' with a wind speed of ' + wind.speed;
}
callbackFunction()
<script src="https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20weather.forecast%20WHERE%20woeid%3D%222409681%22%20and%20u%3D%22f%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=callbackFunction"></script>
每次我进入我收到页面弹出如下:
无法获取财产 '查询'未定义或空引用
但是,如果我点击否,数据仍然填充..如果它填充数据如果它告诉我一个属性是不确定的? YQL天气API非常复杂。
请注意,您在定义之后调用'callbackFunction'。这就是你得到这个错误的原因。 – dlopez