Can someone help me troubleshoot this code? I've been struggling to extract elements from this JSON data. Here's what I have so far:
$(document).ready(function() {
$.getJSON('http://free.worldweatheronline.com/feed/weather.ashx?q=Stockholm&format=json&num_of_days=2&key=e8536d3a52101433121710', function(Wdata) {
$.each(Wdata.data, function() {
$('<div id="test"></div>').append(
this.weather[0].date;
).appendTo('body');
});
});
});
This is how my HTML appears:
<!doctype html>
<html lang="se">
<head>
<meta charset="utf-8" />
<title>Title of This Web Page</title>
<script src="scripts\jquery-1.8.2.js" type="text/javascript"></script>
<script src="scripts\js.js" type="text/javascript"></script>
</head>
<body>
<div id="test">
</div>
</body>
</html>
Here is a snippet of the JSON data:
{
"data": {
"current_condition": [ … ],
"request": [ … ],
"weather": [
{
"date": "2012-10-17",
"precipMM": "0.8",
"tempMaxC": "11",
"tempMaxF": "51",
"tempMinC": "8",
"tempMinF": "46",
"weatherCode": "119",
"weatherDesc": [
{
"value": "Cloudy"
}
],
"weatherIconUrl": [
{
"value": "http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0003_white_cloud.png"
}
],
"winddir16Point": "SW",
"winddirDegree": "224",
"winddirection": "SW",
"windspeedKmph": "27",
"windspeedMiles": "17"
},
{ … }
]
}
}