Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:31:18+00:00 2026-05-24T09:31:18+00:00

I am reading a Rss feed using setInterval method and displaying notification to the

  • 0

I am reading a Rss feed using setInterval method and displaying notification to the users ,I want to make sure I store the latest feed title so that the user does not get multiple notification of the same title again. So I declare a global var global_Rsstitle at the top of my notification.js . Now I try to pass the value of entry_title to the global var the value is not being retained in the global var after the setinterval method is called. Is there a better way of storing the value of entry_title and checking each time the setInterval method is called so as to avoid multiple notification of the same title.

My notification.js

/** global variable **/

var global_Rsstitle;

/** end global variable **/
function get_rss1_feeds() {

    var Rss1_title = getRss("http://rss.cnn.com/rss/cnn_topstories.rss", function(entry_title) {
        if(global_Rsstitle != entry_title)
        global_Rsstitle = entry_title;
        console.log('test',global_Rsstitle); // the value is outputed but global var is not working
    });
console.log('test1',global_Rsstitle);   // outputted as undefined ??
    }

    google.load("feeds", "1");
    google.setOnLoadCallback(function () { setInterval(get_rss1_feeds, 5000); });

My jsRss.js file

function getRss(url, callback){
    if(url == null) return false;

    // Our callback function, for when a feed is loaded.
    function feedLoaded(result) {
        if (!result.error) {
            var entry = result.feed.entries[0];
            var entry_title = entry.title; // need to get this value
            callback && callback(entry_title);        
        }
    }
    function Load() {       
        // Create a feed instance that will grab feed.
        var feed = new google.feeds.Feed(url);
        // Calling load sends the request off.  It requires a callback function.
        feed.load(feedLoaded);      
    }    
    Load();             
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:31:19+00:00Added an answer on May 24, 2026 at 9:31 am

    Shouldn’t you be setting global_Rsstitle and not Rsstitle?

    var global_Rsstitle;
    
    /** end global variable **/
    function get_rss1_feeds() {
    
        var Rss1_title = getRss("http://rss.cnn.com/rss/cnn_topstories.rss", function(entry_title) {
            if(global_Rsstitle!= entry_title)
            global_Rsstitle = entry_title;
            console.log('test',global_Rsstitle); // the value is outputed but global var is not working
        });   
    }
    

    UPDATE

    You do realize that you cant use that variable until the response comes back, right?

    In other words, you can’t do this:

    get_rss1_feed();
    alert(global_Rsstitle);
    

    because the alert will be trigger before the feed is read and the variable is assigned.. To make it worse, you’re delaying the execution with your interval.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a Rss feed using setInterval method and displaying notification to the
I'm reading and store a RSS feed in my database.I'm using this code <?php
I am reading a RSS feed into nsmutablearray. i want to search the xml
I'm reading a rss feed using simple code: <?php $homepage = file_get_contents('http://www.forbes.com/news/index.xml'); $movies =
I'm Reading many rss feed and store these data in database in my site.
I'm new to php.I'm reading a RSS feed and store in my database table.
I'm reading and store rss feed in my database ,my requirement is if link
Possible Duplicates: (PHP5) Extracting a title tag and RSS feed address from HTML using
When reading my RSS feed with the Thunderbird feed reader, some entries are duplicated.
In my Flex 4 app, I access an RSS feed (I'm using http://news.ycombinator.com/rss as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.