I have a set of data that is created/pulled from a url that has already got parsed json data like so:
[
{
"id": 1,
"school_name": "another school in essex",
"website": null,
"book_id": 27,
"url": "http://localhost:3000/schools/1.json"
},
{
"id": 2,
"school_name": "ddffdfd",
"website": null,
"book_id": 31,
"url": "http://localhost:3000/schools/2.json"
},
{
"id": 3,
"school_name": "ddfdfdffd",
"website": null,
"book_id": 31,
"url": "http://localhost:3000/schools/3.json"
},
{
"id": 4,
"school_name": "4545455454",
"website": null,
"book_id": 31,
"url": "http://localhost:3000/schools/4.json"
}
]
I have got a .each loop that grabs the data and assigns it to (city) parameter so I can grab that city parameter and loop through and just grab what I want from that json out put and use.
var info = '/schools.json';
$.get(info, function(response) {
var jsonData = response
var mapContent = $('').html();
var json = jsonData;
}
function setMarkers(map, json) {
jQuery.each(json, function (index, city) {
console.log(city[id]);
}
}
When I try and access the json object in the .each loop above it gives nothing. How can I access the id from each of the json outputs?
Cheers