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 7636923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:48:30+00:00 2026-05-31T07:48:30+00:00

JavaScript goes here.. and i have many sections of div tag.. i want to

  • 0

JavaScript goes here.. and i have many sections of div tag.. i want to make this script common for all divs that i am using.. where as only the url’s have to change reference with the corresponding div.. plz help..??

<script type="text/javascript">

var feedcontainer1=document.getElementById("feeddiv1")
var rssoutput1="<b>TOI</b><br /><ul>"

function rssfeedsetup1(){
google.load("feeds", "1")
var feedpointer1=new google.feeds.Feed("http://handheld.softpedia.com/backend-software.xml") //Google Feed API method
feedpointer1.setNumEntries(10) //Google Feed API method
feedpointer1.load(displayfeed1) //Google Feed API method
}

function displayfeed1(result){
if (!result.error){
var thefeeds1=result.feed.entries
for (var i=0; i<thefeeds1.length; i++)
rssoutput1+="<li><a href='" + thefeeds1[i].link + "'>" + thefeeds1[i].title + " »" + "</a></li>"
rssoutput1+="</ul>"
feedcontainer1.innerHTML=rssoutput1
}
else
alert("Error fetching feeds!")
}
</script>
  • 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-31T07:48:32+00:00Added an answer on May 31, 2026 at 7:48 am

    You need to create a callback function that knows about where to put the data returned from google. In Javascript, the best way to do this is to use a function closure to remember the destination. Therefore, you need a function that creates the callback, such as:

    // Return function that receives feed data from google and populates the given div.
    function makeDisplayFeedCallback(divId) {
        var destDiv = document.getElementById(divId)
        return function callback(result) {
            var output = "<b>TOI</b><br /><ul>"
            if (!result.error) {
                var entries = result.feed.entries
                for (var i = 0; i < entries.length; i++)
                    output += "<li><a href='" + entries[i].link + "'>" + entries[i].title + " »" + "</a></li>"
                output += "</ul>"
                destDiv.innerHTML = output
            }
            else
                alert("Error fetching feeds!")
        }
    }
    

    This function can be called multiple times, and each time it will return a function that knows how to populate different divs. You’ll call it something like:

    var callback = makeDisplayFeedCallback("feeddiv1");
    setupRssFeed(callback); 
    

    and finally, your setup function needs the callback (and perhaps other parameters):

    function setupRssFeed(callback) {
        google.load("feeds", "1")
        var feed = new google.feeds.Feed("http://handheld.softpedia.com/backend-software.xml");
        feed.setNumEntries(10);
        feed.load(callback);
    }
    

    Overall, this is better separation of concerns as well, so it will be easier to maintain.

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

Sidebar

Related Questions

I have this code here: var fields = row.split(/regex goes here/); I want to
I have a nested div like this <div id=one> <div id=two> id two goes
I have a text <info>SOME CONTENTS GOES HERE</info> How i can remove this text
I have some javascript that goes out and fetches a javascript class on another
I recognise this question probably goes to how Javascript functions operate in general (and
Javascript I have code that will hide various sections in a MS CRM form
I want to have developers write some custom apps for a site in Javascript
I am using classic Javascript for DOM scripting, i have a set of DIV's
I have a webpage that dynamically prepends new divs about once per minute. Here
I have a dilemma that goes like this. I have a string that represents

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.