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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:04:54+00:00 2026-05-28T11:04:54+00:00

Okay so to make a long story short I am using this script in

  • 0

Okay so to make a long story short I am using this script in a jquery mobile envoirment. I am using ajax in it to grab results from the database. I currently works, however it does not refresh automatically. I have read numerous online posts about how to use the set interval function and I have tried that. However when I try it, it works, but it keeps adding duplicate content( the same database record over and over again). I just can’t seem to get this to work. Any help would be much appreciated, thanks in advance!

Here is my code (*not I removed the setinterval function):

 <script type="text/javascript">
$( document ).delegate("#member_home", "pagecreate", function() 
{ 
var member= new Array();
$.ajaxSetup({cache: false})
$.ajax({
url: '/scripts/alert_display.php',
data: "",
isajax: 1,
dataType: 'json',
success: function(data)
  {
    $.each(data, function(key, val) {

var friend = val['friend'];

$('#member_alerts').append(friend+"&nbsp;Wants to be your friend<input type='hidden' value='"+friend+"' id='hidden4' /><button type='submit' id='add'>Accept</button><br />");
                                                         });
                                                  }
                                           });

                                 })
                    </script>

Thank you so much for the help, so just to be clear, my code should now look like this?:

<script type="text/javascript">
$( document ).delegate("#member_home", "pagecreate", function() 
{ 
var refreshId = setInterval(function()
{
var member= new Array();
$.ajaxSetup({cache: false})
$.ajax({
url: '/scripts/friend_request_display.php',
data: "",
isajax: 1,
dataType: 'json',
success: function(data)
  {
    $.each(data, function(key, val) {

var friend = val['friend'];

$('#member_alerts').html(friend+"&nbsp;Wants to be your friend<input type='hidden' value='"+friend+"' id='hidden4' /><button type='submit' id='add'>Accept</button><br />");
                                                         });
                                                  }
                                           });
               }, 1000);
                                 })
                    </script>
  • 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-28T11:04:54+00:00Added an answer on May 28, 2026 at 11:04 am

    It keeps adding duplicate content because you’re using the append function, which adds to the current DOM in the element. Use html instead (you may also need to create the div tags). See this SO question for more info.

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

Sidebar

Related Questions

Okay I am trying to make minecraft mods using eclipse. I used this video
Is okay to break all dependencies using interfaces just to make a class testable?
okay i making a jQuery plugin to make a slide down menu on click,
Okay i have this problem with every page i make. im not sure what
First of all, I am using PhpMyAdmin , is this okay or not? Because
Okay so I am trying to make a histogram from a three dimensional array
Okay this makes a mobile webpage not be able to zoom: <meta name=viewport content=width=device-width,
Okay so I want to make an application that launches other applications. However, the
Okay so I'm trying to make a little gag program that will run away
Okay so im working on this php image upload system but for some reason

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.