【发布时间】:2010-07-12 17:08:58
【问题描述】:
在下面的代码中,我尝试遍历 JSON 对象字符串。但是,我没有得到想要的输出。我在网页上的输出类似于:-
+item.temperature++item.temperature++item.temperature++item.temperature+
输出温度的警报运行良好。我尝试通过遍历 JSON 对象字符串来访问值的部分似乎不起作用。有人可以帮我解决这个问题吗?
代码
<body>
<script>
$.getJSON('http://ws.geonames.org/weatherJSON?north=90&south=-9.9&east=-22.4&west=55.2',
function(data) {
$.each(data.weatherObservations, function(i, item) {
$("body").append("+item.temperature+");
if (-i == 3-) return false;
});
alert(data.weatherObservations[0].temperature);
});
</script>
</body>
【问题讨论】:
标签: javascript jquery json iterator