我正在尝试使用 $.getJSON 解析 JSON 字符串。字符串结构是这样的:
{"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"}]}
这是我尝试使用的代码,但没有成功(我获得了一个未定义的值)
<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>
有什么帮助吗?提前致谢!