2010-09-13 21 views
0

我對每個Google Feed API和jQuery都有點問題。jquery each和Google API - Page正在重新加載,但爲什麼?

問題:

我得到一個重載的時候我就開始按鈕點擊。

有人可以解釋我爲什麼嗎?

HTML

<input type="button" onclick="tkk_rss_check();" value="start"/> 

JS

$(document).ready(function trt() 
{ 
    tkk_rss = {}; 
    tkk_rss['32'] = new Array("gulli:News", "http://ticker.gulli.com/rss", "0", "gulli:News", "0", "gle", "0"); 
    tkk_rss['36'] = new Array("Golem.de", "http://rss.golem.de/rss.php?feed=RSS1.0", "155", "IT-News fuer Profis", "0", " ", "0"); 
    tkk_rss['37'] = new Array("Heise", "http://www.heise.de/open/news/news-atom.xml", "156", "", "0", "", "0"); 

}); 

function tkk_rss_check() 
{ 
    $('body').append('Start<hr />'); 
    google.load("feeds", "1"); 

    $.each(tkk_rss, function(i, val) 
    { 
     function initialize() { 
      var feed = new google.feeds.Feed(''+tkk_rss[i][1]+''); 
      feed.setNumEntries(10); 
      feed.load(function(result) { 
      if (!result.error) { 
       for (var i = 0; i < result.feed.entries.length; i++) { 
       var entry = result.feed.entries[i]; 
       var attributes = ["title", "link", "publishedDate", "content", "contentSnippet"]; 
       $('body').append(''+entry[attributes['0']]+' <br />'); 
       } 
      } 
      }); 
     } 
     google.setOnLoadCallback(initialize); 

    }); 
} 

工作示例的提前 http://www.jsfiddle.net/V9Euk/587/

謝謝! 彼得

回答

2

您需要抑制按一下按鈕,如下所示:

<input type="button" onclick="tkk_rss_check(); return false;" value="start"/> 
相關問題