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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:44:42+00:00 2026-05-14T00:44:42+00:00

I have a news feed where items in the feed are created from JSON

  • 0

I have a news feed where items in the feed are created from JSON returned from a server. When the user takes an action on an item, I want to remove it from the object via javascript.

The feed looks like this:

{"newsFeed":[{"feedId":"1",
              "title":"item1 title",
              "desc":"description of the item"},
             {"feedId":"2",
              "title":"item2 title",
              "desc":"description of the item"}]}

I’m trying to remove a JSON attribute or entry where the feedId is passed in via a variable using jQuery. I’m not sure exactly where I’m going wrong here, but when I alert the feed before and after the removal of the object, I’m getting the same response:

function removeFromFeed(feedId){
  var newsFeed=jQuery('div#newsFeed').data('newsFeed');
  alert(newsFeed.toSource());
  delete newsFeed.feedId[feedId]
  jQuery('div#newsFeed').data('newsFeed',newsFeed);
  alert(newsFeed.toSource());
}
  • 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-14T00:44:42+00:00Added an answer on May 14, 2026 at 12:44 am

    If I undertand you correctly you want to remove e.g. this whole entry {"feedId":"1", "title":"item1 title", "desc":"description of the item"} if removeFromFeed(1) is called.

    So what we need to do is remove an entry from an array.

    New version which should work now. (btw. what is this toSource() my browser doesn’t know this method)

    //http://ejohn.org/blog/javascript-array-remove/
    Array.prototype.remove = function(from, to) {
        var rest = this.slice((to || from) + 1 || this.length);
        this.length = from < 0 ? this.length + from : from;
        return this.push.apply(this, rest);
    };
    
    function removeFromFeed(feedId){
        var data = jQuery('div#newsFeed').data('newsFeed');
        var len = data.newsFeed.length;
        for (var i = 0; i < len; i++) {
            if (data.newsFeed[i].feedId == feedId) {
                data.newsFeed.remove(i);
                break;
            }
        }
        jQuery('div#newsFeed').data('newsFeed', data);
    }
    

    Demo: http://jsbin.com/ekali3 (Code view: http://jsbin.com/ekali3/edit)

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

Sidebar

Related Questions

On a news-feed page I've created I have a list of snippets with information,
Suppose I have a class that downloads a news feed from the web public
from a PHP script I'm downloading a RSS feed like: $fp = fopen('http://news.google.es/news?cf=all&ned=es_ve&hl=es&output=rss','r') or
I have an UL: <ul id=news-feed>.....</ul> I'd like to be able to append a
What I have so far I am creating a news feed for my site
I am downloading and parsing JSON objects to build a news feed to populate
I have a news feed that has been developed using PHP, MySQL, and jQuery.
Taking the BBC News RSS feed for example, one of their news items is
I'm creating a social network. I want to have a user be able to
I have a page that is loading a script from a third party (news

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.