I'm trying to extract the image post URLs from a subreddit feed, and render <img>
elements on my page.
Been trying to hack together the .getJSON()
Flickr example from the jQuery Docs for a while now and I'm not getting anywhere.
Code in question:
$.getJSON('http://www.reddit.com/r/pics.json', function (data) {
$.each(data.children, function (i, item) {
$('<img/>').attr("src", url).appendTo("#images");
});
});
In the body, I have the element: div#images
I understand that I need to use JSONP, but not sure how. Can somebody point me in the right direction?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…