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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:26:29+00:00 2026-05-29T18:26:29+00:00

Basically, I have one div(divNew) which is being populated with content from another page(thread.php)

  • 0

Basically, I have one div(divNew) which is being populated with content from another page(thread.php) using ajax. thread.php is constantly refreshed to poll data from the database.

I want the content from divNew to be appended to another div(chatContents) everytime there is content in divNew.For this i am am constantly running the javascript which does the appending.
The problem i am facing is that the appending takes place as long as thread.php hasnt refreshed. But once it does, all the appending that took place is deleted and is replaced with what was there originally. And the cycle repeats every time thread.php is refreshed.

I am not sure if i am explaining this properly. I hope the code helps.

    <script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<div id = "divNew" name = "divNew">
</div>
<h2>Greetings</h2>
<div class="container" id = "chatContents">
  <div class="inner">Hello</div>
  <div class="inner">Goodbye</div>
</div>

<script>
 existingdiv1 = document.getElementById('divNew');


</script>
<script language="JavaScript">

setInterval("returnValue()", 1000); 
function returnValue()
{

 $.ajax({
            async: true,
            type: "GET",
            url: "thread.php",
            data: "html",
            success: function (html) {
                $("#divNew").html(html);   

            $('.inner').append([existingdiv1]);             
            }  
        });

}
</script>

Any help would be appreciated. Thanks 🙂

  • 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-29T18:26:30+00:00Added an answer on May 29, 2026 at 6:26 pm

    I would do away with the concept of #newDiv and do something like this:

    You were also importing jQuery twice. I took one out.

    Html

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
    <h2>Greetings</h2>
    <div class="container" id="chatContents">
      <div class="inner">Hello</div>
      <div class="inner">Goodbye</div>
    </div>
    

    JS

    setInterval("returnValue()", 1000); 
    function returnValue()
    {
     $.ajax({
                async: true,
                type: "GET",
                url: "thread.php",
                data: "html",
                success: function (html) {
                    if(html)
                    {
                       var newDiv = $('<div/>').html(html);   
                       $('#chatContents').append(newDiv);             
                    }
                }  
            });
    }
    </script>
    

    This will just generate a new div and append it when you get stuff back from the server.

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

Sidebar

Related Questions

I have one line of code which seems commented. Basically the thing I want
I have a multi-dimensional array, which basically consists of one sub-array for each year.
I have an MFC application. It is basically just copying files from one drive
I basically have a page which shows a processing screen which has been flushed
I have two pages one is the main page and the another one is
I have this code. Trying to pass form values from one internal page to
How to take content from a div class one by one and then load
Basically I have some class objects, each with three properties. Once one class object
Basically, I have a class with 2 methods: one to serialize an object into
I have an ASP.NET application. Basically the delivery process is this one : Nant

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.