0

I saw a similar post to this, so I tried to follow the answer of that question but it didn't work. Where is my mistake? I think it should display "My function can run here :)". But both RSS feeds and this alert dont appear.

    google.load("feeds", "1");
function initialize(callback) {
  var feed = new google.feeds.Feed("http://www.ntvmsnbc.com/id/24927681/device/rss/rss.xml");
  feed.setNumEntries(6);

  feed.load(function(result) {}){
    if (!result.error) {
      var container = document.getElementById("feed");
      var html = '';
      for (var i = 0; i < result.feed.entries.length; i++) {
        var entry = result.feed.entries[i];
        var a= " ";
        a += entry.title;
        info[i] = a;
        callback();
       html += '<p>' + entry.publishedDate + '&nbsp' + entry.title;
      }
      container.innerHTML = html;
    }
  });
}
google.setOnLoadCallback(function(){

//Run the Initialize Function
initialize(function(){
     //Run anything else here like
     alert("My function can run here :)")  
});
});

Ok I'm updating my question =). Instead of this alert, can I add entry.title into an array in this function? If yes, what should I write there

2
  • this is where I got the example stackoverflow.com/questions/4572959/… Commented Jul 23, 2012 at 14:31
  • feed.load(function(result) {}){ //should be just: feed.load(function(result)){ Commented Jul 23, 2012 at 14:32

1 Answer 1

1

Looks like you've mixed up some syntax:

feed.load(function(result) {}){

should be

feed.load(function(result){
Sign up to request clarification or add additional context in comments.

2 Comments

So this was indeed the fix? or...?
actually I created a global array. I want to add entr.titles into this array. I heard that I should use anonymous function. So I don't know what should I write inside initialize(function(){}). Do you have any idea?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.