getJSON , trying to ouput some text but can't [solved]
I have a php script that echoes out a json type of file like this:
-
({
"title": "CommentLuv Output",
"link": "http://www.commentluv.com",
"description": "",
"generator": "http://www.CommentLuv.com/",
"items": [
{
"title":"Why don?t they understand?"},"url":"http://www.fiddyp.co.uk/why-dont-they-understand/"
},
{
"title":"CommentLuvvers - Interesting sites that use CommentLuv"},"url":"http://www.fiddyp.co.uk/commentluvvers-interesting-sites-that-use-commentluv-3/"
},
{
"title":"We iz the kitty that says Niii"},"url":"http://www.fiddyp.co.uk/we-iz-the-kitty-that-says-niii/"
},
{
"title":"The Archimedes Commentluv Principle"},"url":"http://www.fiddyp.co.uk/the-archimedes-commentluv-principle/"
},
{
"title":"Beware the believers!"},"url":"http://www.fiddyp.co.uk/beware-the-believers/"
},{"title":"Made by CommentLuv.com","url":"http://www.commentluv.com"}
]
})
I am able to see this passed back to the page after doing
-
$.getJSON("http://www.commentluv.com/commentluvinc/remoteCL3.php5?url=http://www.fiddyp.co.uk&type=json&jsoncallback=?",function(data){
//I want to output a list of html links using <a href='url'>title</a> from each item
}
how do I access each items 'title' and 'url' and output it?? maybe an .each or similar? maybe my json output is wrong but I can't access any of the items details in the function and I don't know why
this is what I originally tried..
hope you can help, I've been at it for ages!!
-
<script>
$(document).ready(function(){
$.getJSON("http://www.commentluv.com/commentluvinc/remoteCL3.php5?url=http://www.fiddyp.co.uk&type=json&jsoncallback=?",
function(data){
$.each(data.items, function(i,item){
$('#out').append('<a href="'+ item.url+'">'+item.title+'</a>');
});
});
});
(there is a div with id "out" on the page)
is it my code or my json output?
thanks for listening..
Andy