Reputation: 1
I don't want to parse all title from the list. I only want the first title to be parsed. Any suggestion?
function parseRSS(url, container) {
$.ajax({
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
dataType: 'json',
success: function(data) {
$.each(data.responseData.feed.entries, function(key, value){
var thehtml = '<h3><a href="'+value.link+'" target="_blank">'+capitaliseFeed(value.title)+'</a></h3>';
$(container).append(thehtml);
});
}
});
}
function capitaliseFeed(string) {
return string.toUpperCase();
}
Upvotes: 0
Views: 96
Reputation: 2234
Instead of $.each
you could loop the data and keep only the first entry
for (var i = 0; i < data.responseData.feed.entries.length; i++) {
var entry = data.responseData.feed.entries[i];
var thehtml = '<h3><a href="'+entry.link+'" target="_blank">'+capitaliseFeed(entry.title)+'</a></h3>';
$(container).append(thehtml);
break;
}
Upvotes: 1