I know this is an incredibly easy question, but I am struggling with it. Here is a section of the JSON:
"forecast": {
"txt_forecast": {
"date": "7:52 AM MDT",
"forecastday": [
{
"period": 0,
"icon": "partlycloudy",
"icon_url": "http://icons.wxug.com/i/c/k/partlycloudy.gif",
"title": "Thursday",
"fcttext": "Partly cloudy. High near 90F. Winds W at 10 to 15 mph.",
"fcttext_metric": "Sunshine and clouds mixed. High 32C. Winds W at 15 to 25 kph.",
"pop": "10"
},
{
"period": 1,
"icon": "nt_partlycloudy",
"icon_url": "http://icons.wxug.com/i/c/k/nt_partlycloudy.gif",
"title": "Thursday Night",
"fcttext": "Partly cloudy skies. Low 71F. Winds SSE at 5 to 10 mph.",
"fcttext_metric": "Partly cloudy. Low 22C. Winds SSE at 10 to 15 kph.",
"pop": "0"
},
And here is the code that I have on my website:
<script>
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/b18485d6da512c58/geolookup/forecast/q/UT/SLC.json",
dataType : "jsonp",
success : function(parsed_json) {
var title = parsed_json['forecast']['txt_forecast']['forecastday']['period.0']['title'];
document.getElementById('day').innerHTML = title;
}
});
});
</script>
I want to assign the value of title within period 0 to the variable 'title'. How do I do that?
Thanks.