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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:38:03+00:00 2026-06-15T17:38:03+00:00

I created a simple chat application which broadcasts all the connected usernames to all

  • 0

I created a simple chat application which broadcasts all the connected usernames to all the users who are connected to a server. The list of usernames will be refreshed whenever a new user is connected.

My problem is that.. The list of connected users is showing good only to the newly connected user and the others, the list is full of duplicate usernames as you can see in the below image:

enter image description here

I dont understand why this is happening.. To make it clear to understand, I am even clearing the div showUsernames in which the list of usernames are being displayed.

Please have a look at the below code which is related to this problem. (as the users are increasing the list for the first connected user is increasing too, then second, third, fourth…)

chat.client.joins = function () {

    //calling the server side method "GetConnectedUsers"
    //The return value of the method is stored in a variable "users"
    chat.server.getConnectedUsers().done(function (users) {
        //clearing the div, to fill it again 
        $('#showUsernames').val('');
        console.log(users.length);
        //calling each username stored in a static dictionary on server side using for loop
        for (var i = 0; i < users.length; ++i) {
            $('#showUsernames').append('<li>' + users[i].Name + '</li>');
        }
    });
};
  • 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-06-15T17:38:04+00:00Added an answer on June 15, 2026 at 5:38 pm

    You’re not checking for already connected users.

    The quickest way around this would be to empty the list first.

    $('#showUsernames').empty();
    for (var i = 0; i < users.length; ++i) {
      $('#showUsernames').append('<li>' + users[i].Name + '</li>');
    }
    

    line 72 of files.js

    EDIT: I now see you are attempting to clear the list using .val(''). This won’t work, as .val() is only meant for input elements etc. .empty() would work here, as shown above.

    So, line 70 of files.js – switch .val('') with .empty()

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

Sidebar

Related Questions

I want to to create a simple client/server chat application. The idea is that
I have created a simple chat server that is driven by client polling. Clients
I have created simple chat application using smack api.i can able to chat well.but
I just created a simple chat client and it only works when all clients
hi i created a simple php/mysql/Ajax chat application and I have a few questions.
I have created a simple text chat application for android device using flex 4
I'm trying to create a very simple chat application in Flex/.Net using FluorineFX but
I am trying to create a simple chat client using the red5 media server,
Hello I`ve created simple WFC DataService and connected entit model with my database. This
i am writing a simple client/server chat program with indy 10 (blocking mode) 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.