Getting a specific number of JSON items with jQuery from tumblr feed
Posted
by Kevin Whitaker
on Stack Overflow
See other posts from Stack Overflow
or by Kevin Whitaker
Published on 2010-05-25T21:12:08Z
Indexed on
2010/05/25
21:21 UTC
Read the original article
Hit count: 422
Hello all.
I'm trying to populate a page with X entries from my tumblr feed, and I'm wondering how I can only pull that X number from the JSON object it returns.
Here's my code, pulled from another Stack Overflow post and modified:
//Tumblr retrieval
$.getJSON("http://tumblr-address/api/read/json?callback=?",
function(data) {
$.each(data.posts, function(i,posts){
var title = this["regular-title"];
var type = this.type;
var date = this.date;
var url = this["url-with-slug"];
$('#sideRail ol').prepend('<li><p><a href=' +url +'>' + title + '</a></p><p>' + date + '</p></li>');
});
});
I've tried using a while loop with a counter, but it just repeats everything X times before moving on to the next item in the list.
Thanks for any help.
© Stack Overflow or respective owner