striker
striker

Reputation: 29

Weather Underground Hourly 1-day Forecast

I am taking the Weather Underground API, using json and parsing variables. I have an issue. I cannot figure out how to display the hourly 1-day forecast like something like so:

Hourly Forecast 11AM EST on January 25, 2015

60F 55F Mostly Cloudy

16 MPH NNW 41

60F

This will explain more https://www.youtube.com/watch?v=S6A138NBuyk&feature=youtu.be at 3:30 time.

Here is the code I have so far:

$.ajax({
    url: "http://api.wunderground.com/api/72df18b7f213607b/hourly/q/CO/Alamosa.json",
    dataType : "jsonp",
    success : function(parsed_json) {
        var hourly = parsed_json['hourly_forecast']['FCTTIME'];


        for(index in hourly)
            var newHourly = 'Today is' + hourly_forecast[index]['weekday_name'];
            $(".hourFore").append(newHourly);
    }

});

Here is the weather underground api doc for hourly: http://www.wunderground.com/weather/api/d/docs?d=data/hourly&MR=1

Upvotes: 1

Views: 1193

Answers (1)

charlietfl
charlietfl

Reputation: 171679

hourly_forecast is an array of objects that contain FCTTIME in each.

I'm not going to try and parse all the various components of it for you but you can see the general approach to accessing it here:

$.getJSON('http://api.wunderground.com/api/72df18b7f213607b/hourly/q/CO/Alamosa.json',function(resp){
    $.each(resp.hourly_forecast, function(){
        logTime(this.FCTTIME);        
    });

});

function logTime( obj){
    $('body').append(obj.weekday_name + ' '+  obj.civil +'<br>');
    console.log(obj);
} 

DEMO

Upvotes: 1

Related Questions