user279321
user279321

Reputation: 57

JQuery: Asynchronously loading DIV tag(only) with latest feed using Google-Ajax-Feed-API

I am writing a code using Google-Ajax-Feed-API to get latest feeds from some site. I want the feeds to be checked for update every(say 1 secs?). I am able to retrieve the blogs but not able to refresh the DIV tags. Any help will be useful.

 <script type="text/javascript">
        google.load("feeds", "1");
        $(document).ready(function(){
          setInterval(  initialize(),10000)
        }); 
          function initialize() {
            var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
            feed.setNumEntries(6);
            feed.load(function(result) {
                if (!result.error) {
                    var container = document.getElementById("feed");
                    for (var i = 0; i < result.feed.entries.length; i++) {
                        var entry = result.feed.entries[i];
                        var div = document.createElement("div");
                        div.appendChild(document.createTextNode(entry.title));
                        container.appendChild(div);
                    }
                }
            });
    }
    </script>

Thanks.

Upvotes: 1

Views: 959

Answers (1)

NicolasT
NicolasT

Reputation: 192

setInterval('initialize()',10000)

You need the quotes

To refresh every 1 second use:

setInterval('initialize()',1000)

Upvotes: 1

Related Questions