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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:28:33+00:00 2026-06-01T12:28:33+00:00

$(function() { setInterval(function() { $.get(refresh.php, function(result) { $(‘#response’).empty() .hide() .html(result) $(#response).append(result) .fadeIn(slow); }); },

  • 0
$(function() {
    setInterval(function() {
        $.get("refresh.php", function(result) {
            $('#response').empty()
            .hide()
            .html(result)
            $("#response").append(result)
            .fadeIn("slow");
        });
    }, 5000);
});

actually my script hits refresh.php every 5seconds in refresh.php i fetch data from mysql db and create a template like:

<table>
<tr><td>Name<td><td>$fetch['name']</td></tr>
</table>

I checked on firebug my refresh.php send response only once after 5seconds but on all browsers it shows the result two times like:

<table>
    <tr><td>Name<td><td>$fetch['name']</td></tr>
    </table>
<table>
    <tr><td>Name<td><td>$fetch['name']</td></tr>
    </table>
  • 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-01T12:28:34+00:00Added an answer on June 1, 2026 at 12:28 pm

    It shows the result twice because you’re putting it there twice: First using html, then using append:

    $(function() {
        setInterval(function() {
            $.get("refresh.php", function(result) {
                $('#response').empty()
                .hide()
                .html(result)                 // <==== Here
                $("#response").append(result) // <==== And here
                .fadeIn("slow");
            });
        }, 5000);
    });
    

    html replaces the content of the element with the markup (or element[s]) you supply (there’s no need for empty prior to using it). append appends the markup (or element[s]) you supply to the element.

    You want one or the other. I’d go with html:

    $(function() {
        setInterval(function() {
            $.get("refresh.php", function(result) {
                $('#response')
                    .hide()
                    .html(result)
                    .fadeIn("slow");
            });
        }, 5000);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the simple jQuery DIV refresh code. var refreshId = setInterval(function() { $('#refreshdash').load('dashboard.php?cache=');
i made a chat application, here is the refresh code setInterval(function() { $('#DisplauDiv').load('show-chat.php?session=<?php echo
I am writing a tail function in PHP, and using jQuery to refresh a
Currently im polling/checking every 1000ms by doing a GET to /moves: jQuery(document).ready(function() { setInterval(function()
I have a notification system that works with the following codes jQuery: $(document).ready(function(){$.get('/codes/php/nf.php', function(data)
p2 = setInterval(function () { clearInterval(p2); some code here; }, waitTime) I need to
I have a jQuery setInterval function named timerIncrement that times out (stops incrementing the
Here is my code: var showNo = 1; window.setInterval(function() { console.log(showNo); if(showNo === 1)
I have a function that use setInterval() method to watch css propertie change('cause in
I have written a javascript function that uses setInterval to manipulate a string every

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.