10dayfor cast question

  • 1
  • Question
  • Updated 4 years ago
  • (Edited)
hi i want to add the 10day forecast  but how do set this up in my page 

jQuery('#GetWeather').click(function() {
var PostCode=" ";<br>$.ajax({ url : "http://api.wunderground.com/api/33ff9656c9b34818/geolookup/forecast/q/QLD/Townsville"+PostCode +".json",
dataType : "jsonp",
success : function(parsed_json) {

var Forcast = parsed_json['forecast']['simpleforecast']['forecastday'];

for (index in Forcast) {
var imageurl = "http://.....";
/* Weather Box 0 Day 1, 1st period */
$('.Wicon').css('background-image',"url("+imageurl+Forcast[0]['icon']+".svg)");
$('#GetWeatherDay').html(Forcast[0]['date']['weekday']);
$('#GetWeatherState').html(Forcast[0]['conditions']);
$('#GetWeatherTempHigh').html('High of '+Forcast[0]['high']['celsius']+'&amp;#8451');
$('#GetWeatherTempLow').html('Low of '+Forcast[0]['low']['celsius']+'&amp;#8451');
$('#GetWeatherMaxWind').html('Max Wind '+Forcast[0]['maxwind']['mph']+' Mph');
$('#GetWeatherAveWind').html('Average Wind '+Forcast[0]['avewind']['mph']+' Mph');
$('#GetWeatherWindDir').html('Wind Direction '+Forcast[0]['avewind']['dir']);
$('#GetWeatherHumidityA').html('Average '+Forcast[0]['avehumidity']+'%');
Photo of matrixstorms

matrixstorms

  • 8 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
hey, tried to paste your code (with little edits) over jsfiddle at http://jsfiddle.net/khcskn6o/

it needs to query a different URL, since it triggers the infamous ambiguous results event (see at bottom of http://www.wunderground.com/weather/api/d/docs?d=data/index ) so you may need to refine your URL building pattern.
according to my confidence with the api, I would also encourage building location segment in URLs using full country names if outside US, so i repalced QLD with Australia to directly get usable data.
Photo of matrixstorms

matrixstorms

  • 8 Posts
  • 0 Reply Likes
how can i set it to the ten day forecast with images mike thankyou for replying back to me
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
For ten days forecast, you can use the forecast10day feature (see http://www.wunderground.com/weather/api/d/docs?d=data/forecast10day for reference) so with a little of programming skills you can upgrade your code and cycle with a for loop to display forecast datas.

About images from original code, it seems you planned to use some svg icons of yours, so just a final path needs to be specified for imageurl variable.

WU also provides complimentary icon sets, see http://www.wunderground.com/weather/api/d/docs?d=resources/icon-sets for usage and availability.
This document also discloses out available dictionary for icons returned via "icon" field in API response.