每个Jquery和Google API - 页面正在重新加载,但为什么呢?

时间:2010-09-13 14:01:04

标签: jquery

我对Google Feed API和jquery都有一点问题。

问题:

点击开始按钮后,我重新加载。

有人能解释我为什么吗?

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/

提前致谢! 彼得

1 个答案:

答案 0 :(得分:2)

您需要按下按钮,如下所示:

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