Trouble displaying forecast

  • 1
  • Question
  • Updated 6 years ago
Using the temp code example, it works fine, so I tried to convert that to display the forecast but all I get is either undefined, or [object][object] etc. I'm assuming I'm displaying calls incorrectly.

This is the code I'm trying to use:

jQuery(document).ready(function ($) {
$.ajax({
url: "http://api.wunderground.com/api/mykey...",
dataType: "jsonp",
success: function (parsed_json) {
var forecast = parsed_json['forecast']['txt_forecast']['forecastday']['fcttext'];
alert("Current forecast is: " + forecast);
}
});
});
Photo of kjetty75

kjetty75

  • 1 Post
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
You missed an array, under forecastday.

Usa a code like
var forecast = parsed_json['forecast']['txt_forecast']['forecastday'][0]['fcttext'];