Here is what I have:
function HelloFeed(WPFeedUrl) {
var title, articles;
WinJS.xhr({ url: WPFeedUrl }).then(function (rss) {
title = rss.responseXML.querySelector("title").textContent;
var items = rss.responseXML.querySelectorAll("item");
for (var n = 0; n < items.length; n++) {
var article = {};
article.title = items[n].querySelector("title").textContent;
var thumbs = items[n].querySelectorAll("content");
article.content = items[n].querySelector("encoded").textContent;
if (thumbs.length > 1) {
article.thumbnail = thumbs[thumbs.length - 1].attributes.getNamedItem("url").textContent;
}
else {
var firstindex = article.content.indexOf("<img");
if (firstindex !== -1) {
var secondindex = article.content.indexOf("src=", firstindex) + 5;
var thirdindex = article.content.indexOf("\"", secondindex);
article.thumbnail = article.content.slice(secondindex, thirdindex);
}
}
BasketballItems.push({ group: BasketballGroups[0], title: "hello", content: "h", backgroundImage: lightGray });
}
});
}
If I place BasketballItems.push({ group: BasketballGroups[0], title: "hello", content: "h", backgroundImage: lightGray });
outside the WinJS.xhr
block of code, it successfully adds an element to the array BasketballItems
, however if I put it inside that big block of code, it doesn't function. I am calling the function like this: HelloFeed("http://allball.blogs.nba.com/feed/");
What am I doing wrong?