I have the following jQuery (info from here http://www.threelas.com/2012/02/basic-blogger-json-feed-api.html). the problem i am having is returning the labels array which on the website above says is json.feed.entry[i].category[]; so how can i return an array?
http://jsfiddle.net/Pd2cp/
$.ajax({
url: 'http://www.blogger.com/feeds/2814965631975331659/posts/default?alt=json-in-script&max-results=8',
type: 'get',
dataType: "jsonp",
success: function(data){
for (var i = 0; i < data.feed.entry.length; i++){
var categories = data.feed.entry[i].category[];
$('#blogContainer').append(categories);
}
}
});
I edited your JSFiddle. Here are the changes:
callbackparameter in the query with a value of?to tell jQuery to assign it’s callback here.[]), or you’ll get a syntax error. As you wanted to have the whole Array, I removed the brackets.termvalue to the container.The remaining “problem” is a comma at the end which can probably be removed.
edit: I created a second fork, which also removes duplicates, sorts all categories and accesses the DOM only once. Besides, there are no overlapping commas.