getjson jquery parsing an array
- by Ozaki
TLDR: Want to get each heading from an array and insert it into a div without knowing what is inside the div using Jquery - getJSON.
I have JSON array lets say:
jsonfeed({
"items": [
{
"d":{"title":"034324324-22344231-10"}
},
{
"d"{"title":"23423404-3423422-10"}
},
{
"d"{"title":"0234234324-32432422-10"}
},
{
"d"{"title":"0234234324-223534534-10"}
]
})
And I want to parse it as for each "title" to insert it into a div.
Trying along the lines of
$.getJSON(url,
function(data){
$.each(data.items, function(i,item){
$('#testfield').html('<p>' + item.d.title + '</p>');
});
});
to no avail.
I am using Getjson in other places but in cases where I know what request I am making.
e.g:
$('#livetime').html(data.Time);
Which is all working perfectly fine but in this case I need to get the details out of the array without knowing what is inside the array I'm sure there is something simple that I'm missing here or doing wrong ^^.