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

Ahmet Tanakol
  • 849
  • 2
  • 20
  • 40
  • this is where I got the example http://stackoverflow.com/questions/4572959/can-i-run-a-javascript-function-after-google-loader-has-run – Ahmet Tanakol Jul 23 '12 at 14:31
  • feed.load(function(result) {}){ //should be just: feed.load(function(result)){ – RBZ Jul 23 '12 at 14:32

1 Answers1

1

Looks like you've mixed up some syntax:

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

should be

feed.load(function(result){
Jamiec
  • 133,658
  • 13
  • 134
  • 193
  • So this was indeed the fix? or...? – Jamiec Jul 23 '12 at 14:43
  • 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? – Ahmet Tanakol Jul 23 '12 at 14:52