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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:22:42+00:00 2026-06-15T06:22:42+00:00

I have a problem with my JQuery script. I am making a 2d chat

  • 0

I have a problem with my JQuery script. I am making a 2d chat where people have their own figure like Habbo hotel, but the JQuery script that is suppose to move the figures is bugging.

I think it is easier to show the problem:
Click here to see the problem

I am using the following script to update the figures:

function UpdateRoom() {
    var data = 'roomId='+roomId;

    $.ajax({
        type: "GET",  
        url: "chatfunctions/updateroom.php",
        dataType: 'json',
        data: data,
        success: function(data){

            $.each(data, function(i, data) {
                var temp = parseInt(data.field);
                $('#f' + temp).append('<div class="user" id="'+charId+'" />');
            });
        }
    }); 
}

The #f+temp is the id of the field that the figure should be places at. The charId is the id of the figure.

And then I am calling the script every 500 miliseconds:

window.setInterval(function() {
    UpdateRoom();
}, 500 );

Im not sure if this is enough code and example for you guys to help me. If not please tell me if I need to provide more for you to help me. My guess is that it is the .append(); function that is used wrong, but I’m no expert in JQuery.

  • 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-15T06:22:43+00:00Added an answer on June 15, 2026 at 6:22 am

    You are only continuing to append but not replacing anything.

    Try to either use .html() or .empty().

    $.each(data, function(i, data) {
        var temp = parseInt(data.field);
        $('#f' + temp).html('<div class="user" id="'+charId+'" />');
    });
    

    or

    $.each(data, function(i, data) {
        var temp = parseInt(data.field);
        $('#f' + temp).empty(); // clear out all content
        $('#f' + temp).append('<div class="user" id="'+charId+'" />');
    });
    

    not knowing your code you might need to move the call to .empty() outside your each loop.

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

Sidebar

Related Questions

Hello people i have problem with jquery toggling script.. <a class=clickMe>Text 1</a> </br> <div
I have a problem with the jquery-autocomplete pluging and my django script. I want
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have a small jQuery based script for animating the border on images that
I have a problem with the following HTML/jQuery script. <script type=text/javascript src=jquery-1.7.1.min.js></script> <script type=text/javascript>
I have a script (JS) running that will be making some different divs either
I'm making a dynamic select menu using Jquery mobile. First problem that i am
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have problem to add jQuery to some existing code, please help. We have
I have a problem with jQuery parallax effect for my body's background. Here is

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.