Javascript Jquery处理变量

Javascript Jquery处理变量,javascript,jquery,Javascript,Jquery,第一个outputWeather()没有按预期工作,但第二个工作正常。第一个是在运行时给出一个错误,表示无法设置undefined的属性。我猜变量weather在传递到第一个outputWeather()时正在重置或执行其他操作。如何使第一次调用的outputWeather()与第二次调用的工作相同?谢谢 此外,这里还有outputWeather()函数: if (firstTime !== true) { $('#forecast-table2').removeClass('b

第一个
outputWeather()
没有按预期工作,但第二个工作正常。第一个是在运行时给出一个错误,表示无法设置undefined的属性。我猜变量
weather
在传递到第一个
outputWeather()
时正在重置或执行其他操作。如何使第一次调用的
outputWeather()
与第二次调用的工作相同?谢谢

此外,这里还有
outputWeather()
函数:

if (firstTime !== true) {
        $('#forecast-table2').removeClass('bounceInLeft').addClass('bounceOutRight').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
            outputWeather(weather, "under");
            $(this).removeClass('bounceOutRight').addClass('bounceInLeft');
        });
    } else {
        outputWeather(weather, "under");
    }
问题出现在第11行(
weatherAvg.data.pop.push(weather.pop);

这里是weatherAvg
weatherAvg

function outputWeather(weather, source) {
if (source === "under") {
    var tableNumber = 2;
    $("#weather-location2").html(weather.region);
} else if (source === "yahoo") {
    var tableNumber = 1;
    $("#weather-location1").html(weather.city + ', ' + weather.region);
}
if (tableNumber !== 1) {
    $('#tod-pop'+tableNumber).html(weather.pop+'%');
    weatherAvg.data.pop.push(weather.pop);
}
$("#tod-temp"+tableNumber).html(weather.temp);
weatherAvg.data.temp.push(weather.temp);
}

你从哪里得到的
weatherAvg
?关于它的什么“不起作用”,请你对你的问题再具体一点。除了上面的问题,您的tableNumber在本地设置为if和else if,因此以下if将始终为真,因为它永远不会是1您从何处获得
weatherAvg
?关于它的什么“不起作用”,请您对您的问题更具体一点。与上面的问题一样,您的tableNumber在本地设置为if和else if,因此下面的if将始终为true,因为它永远不会为1
var weatherAvg = {};
weatherAvg.data = {precentop: [], temp: [], high: [],low: [], wind: {speed: [], direction: []}};