This is the JSON object:
{
"temperatures": {
"city": [{
"name": "Riyadh",
"high": [35, 38, 32]
}, {
"name": "New York",
"high": [28, 36]
}, {
"name": "Dubai",
"high": [18, 20]
}]
}
}
On page load I get the object via AJAX. I need to loop through each city and get the name of the city and the high
array as well.
This is the page code:
<html>
<head>
<title>the title</title>
<script type="text/javascript" src="tempj.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.getJSON('temp.json', function(data) {
alert('<ul><li>'+ jd.city.name +':' + jd.high + '</ul> ');
});
});
</script>
</head>
<body>
</body>
</html>