未捕获的类型错误:无法读取属性'条件'的未定义
Uncaught TypeError: Cannot read property 'condition' of undefined
这是我的代码:
var location = 'RPXX0022'; // Find the code of your location in the following link and change this value between the single quotes: http://edg3.co.uk/snippets/weather-location-codes/
var unit = 'c';
var wq = "SELECT * FROM weather.forecast WHERE location='" + location + "' AND u='" + unit + "'";
var cb = Math.floor((new Date().getTime()) / 1200 / 1000);
var wu = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(wq) + '&format=json&_nocache=' + cb;
window['ywcb'] = function(data) {
var info = data.query.results.channel.item.condition;
var city = data.query.results.channel.location.city;
var country = data.query.results.channel.location.country;
$('.ywicon').addClass('wi-yw-' + info['code']);
$('#ywloc').html(city + ", " + country);
$('#ywtem').html(info.temp + '<span>' + '°' + (unit.toUpperCase()) + '</span>');
};
$.ajax({
url: wu,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'ywcb'
});
它给出了这个错误:
未捕获的类型错误:无法读取未定义的属性"condition"
检查项目对象中是否存在条件
var info = data.query.results.channel.item.condition;
此外,在这一行中设置一个调试器,并检查您是否在信息变量中获得任何值
相关文章:
- 主干中的模型属性未定义
- JavaScript 2d 数组导致“无法读取未定义的属性'未定义'”
- JSON对象属性未定义
- Waypoint的循环,退出循环后属性未定义
- Javascript:错误“无法设置属性”..'未定义”
- 翡翠 - 显示对象属性 - 未定义
- 属性未定义,但控制台.log可以看到它
- JavaScript 对象的属性未定义
- Javascript 对象属性未定义(但属性已设置)
- DOM 元素属性未定义 - jquery / ruby on rails.
- Nodejs JSON 属性未定义
- 错误:窗口打开器的属性未定义
- angular Js:Array.lenght属性未定义
- 正在尝试访问JavaScript对象的属性=未定义
- Marionette属性未定义,请从API获取
- AngularJS作用域属性未定义
- 对象的属性未定义,尽管已指定值
- 为什么我一直收到一个错误,说对象属性未定义
- 对象属性未定义,但我看到它不是
- .map()img src属性未定义