getjson jquery parsing an array

Posted by Ozaki on Stack Overflow See other posts from Stack Overflow or by Ozaki
Published on 2010-04-28T07:34:40Z Indexed on 2010/04/28 10:03 UTC
Read the original article Hit count: 455

Filed under:
|
|
|
|

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 ^^.

© Stack Overflow or respective owner

Related posts about JSON

Related posts about jQuery