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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:34:11+00:00 2026-05-22T15:34:11+00:00

I am calling the server every 5 secs to get the data, then looping

  • 0

I am calling the server every 5 secs to get the data, then looping through my list and appending a “span” with the right data to my list. The problem is i can’t make the “span” dissapear when data returned from the server is empty, except when i use “fadeOut()” on the “span”. But then i can’t calculate the right sum of all the “li span” (countCont() ), since they are still appended to the DOM and have a value.
So what i would like to do is remove the respective “li span” if data returned from the server that is assigned to it is empty, so i can calculate the right sum.
Here is how i assign data to my list:

     $.get(url, function (data) {
        $.each(data, function (i, info) {
          $("#accordion li").text(function (y, name) {
            if ($(this).is(":contains(" + info.cName + ")")) {
                if ($(this).is(":has(span)")) {
                    $(this).children().replaceWith('<span class = "cCount">' + info.count + '</span>');
                    $(this).children().fadeOut(10000);
                } else {
                    $(this).append('<span class = "cCount">' + info.count + '</span>');
                }
             }

             countCont($(this).parent().attr('id'));
          });
       });
    });
  • 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-22T15:34:12+00:00Added an answer on May 22, 2026 at 3:34 pm

    After you fade it out, remove it from the DOM using .remove()

    //...
    $("#accordion li").text(function (y, name) {
       var $this = $(this); //also store this, dont select it 5 times
    
       if ($this.is(":contains(" + info.cName + ")")) {
          if ($this.is(":has(span)")) {
             $this.children().replaceWith('<span class = "cCount">' + info.count + '</span>');
             $this.children().fadeOut(10000);
             $this.remove();
          } else {
             $this.append('<span class = "cCount">' + info.count + '</span>');
          }
       }
       countCont($this.parent().attr('id'));
    });
    

    Edit: In response to the comment, this will remove the span if it exists then add a new one on:

    //...
    
    var $this = $(this); //also store this, dont select it 5 times
    
    if ($this.is(":contains(" + info.cName + ")")) {
       if ($this.is(":has(span)")) {
          //remove the span
          var $span = $('span', this);
          $span.fadeOut(10000);
          $span.remove();
       }
       //always append new span
       $this.append('<span class = "cCount">' + info.count + '</span>');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are currently calling web services on our application server through our web server
i am calling ajax every second in page.. Here the server page returns randomly
every one. We know that COM server exsits as dll or ax. We can
I have the following problem: I have a multithreaded server-side application, where every request
We are getting the error below calling c:\windows\syswow64\regsvr32.exe on Windows Server 2008 R2 x64.
I am calling 5 external servers to retrieve XML-based data for each request for
Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need
How can I parse the query string (GET / POST parameters) sent to an
The problem is I have a stored procedure that runs consistently in Sql Server
I've been analyzing a WPF application which basically fetch data from a server and

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.