Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting elements from JSON into html with jQuery not working
    primarykey
    data
    text
    <p>I'm using following code to get some elements out of this JSON, but nothing seems to work. Anybody has an idea of what I'm doing wrong? (I've spent a long time trying to figure it out).</p> <pre><code>$(document).ready(function() { $.getJSON('http://free.worldweatheronline.com/feed/weather.ashx?q=Stockholm&amp;format=json&amp;num_of_days=2&amp;key=e8536d3a52101433121710', function(Wdata) { $.each(Wdata.data, function() { $('&lt;div id="test"&gt;&lt;/div&gt;').append( this.weather[0].date; ).appendTo('body'); }); }); }); </code></pre> <p>my HTML looks like this:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="se"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;Title of This Web Page&lt;/title&gt; &lt;script src="scripts\jquery-1.8.2.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="scripts\js.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="test"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The JSON looks like this:</p> <pre><code>{ "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" }, { … } ] } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload