Reputation: 228
I'm trying to parse a JSON string using $.getJSON. The string structure is this:
{"status":"1","dati":[{"id":"259","temperatura":"27.5\u00b0C","localita":"Perugia (PG)","distanza":"8.94","altitudine":"493","pioggia":"0.0","pressione":"1013.5","vento":"12.9","minima":"15.9","massima":"27.5","orario":"12\/07\/2013 17.35","url":"http:\/\/www.perugiameteo.it\/standardpage.aspx?id=56","webcam":"http:\/\/www.perugiameteo.net\/webcam\/webcam.jpg","raffica":"30.6","rate":"0.0"}]}
and this is the code that I'm trying to use, but without success (I obtain an undefined value)
<ul id="groups"></ul>
<script type='text/javascript'>
$(document).ready(function() {
var $grouplist = $('#groups');
$.getJSON("URL_FILE", function(MyData){
$.each(MyData.dati, function() {
$('<li>' + this.localita + '</li>').appendTo($grouplist);
});
});
});
</script>
Any helps? Thanks in advance!
Upvotes: 2
Views: 105
Reputation: 34846
Since you have proven via jsfiddles in the comments that it works with local data, then it is obviously an AJAX
issue.
Install Fiddler so you can watch the traffic and make the request yourself through Fiddler. It will show the payload being returned.
Upvotes: 1