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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:49:42+00:00 2026-05-23T11:49:42+00:00

I am setting up cycling quotes for a website, and I’m having trouble reloading

  • 0

I am setting up cycling quotes for a website, and I’m having trouble reloading the data when after it has already been used once.

I’ve set up a XML file with a bunch of data. The data includes a quote, an author, and the job title of the author (quote, author, title).

I then have a jQuery .ajax call and store it in the variable xmlData.

xmlData is then used to append or add html to specified id tags.

I am using setInterval() in order to move through the xml data.

The idea is to go through it in a loop like: 1 | 2 | 3| 1| 2 | 3 and so on. But when it comes back around, after the data has been appended to an ID, it doesn’t show up anymore. It is as if the data was removed from the XML file.

Any help would be appreciated. Code is below, along with the website URL where I am working on the test.

<script language="javascript" type="text/javascript">

var xmlData;
var xmlFAILdata;
var nextE = 0;  
var ttlE;
var quote;
var author;
var title;

$(function(){

 $.ajax({
    type: "GET",
    url:"/wp-content/themes/privilegeofpersecution/endorsements.xml",
    data: "",
    dataType:"xml",
    async: false,
    success: function(xml){
        //alert("XML SUCCESS!");
        xmlData = xml;} ,
    error: function(xmlFAIL){
        alert("XML FAIL");
        }
        });

ttlE = $(xmlData).find('endorsement').length;

//Since .length return the number starting at 1 rather than 0 subtract 1 for accuracy
ttlE -= 1;


//On pageload, load in the first Endorsement into variables
quote = $(xmlData).find('endorsement').eq(0).children('quote');
author =$(xmlData).find('endorsement').eq(0).children('author');
title =$(xmlData).find('endorsement').eq(0).children('title');

//Append variables to id containers
$("#quote").html(quote);
$("#author").html(author);
$("#title").html(title);

//executes the function "next" which places the next endorsement
setInterval("next()", 5000);

});

function next(){
    console.log('Next Function Started');

    if(nextE >= ttlE){
        nextE = 0;
        }
    else{
    nextE++;
    }

    console.log('nextE = ' + nextE);

    quote = $(xmlData).find('endorsement').eq(nextE).children('quote');
    author =$(xmlData).find('endorsement').eq(nextE).children('author');
    title =$(xmlData).find('endorsement').eq(nextE).children('title');

    $("#quote").html(quote);
    $("#author").html(author);
    $("#title").html(title);

}
</script>

Here is the website: http://privilegeofpersecution.com/wp-content/themes/privilegeofpersecution/xmltest.html

  • 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-23T11:49:43+00:00Added an answer on May 23, 2026 at 11:49 am

    I was able to fix the problem by adding .clone() to the variable assignment. This way I’m not just placing the XML object in the DOM and overwriting it. rather, I am copying the data from the XML each time I need it so that it stays in tact.

    quote = $(xmlData).find('endorsement').eq(0).children('quote').clone();
    author =$(xmlData).find('endorsement').eq(0).children('author').clone();
    title =$(xmlData).find('endorsement').eq(0).children('title').clone();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Setting up a Windows based web application on Amazon's cloud has definitely been a
Setting up a new database that has a comments table. I've been told to
The Setting: The program in question tries to post form data via an AJAX
Setting: Multiplayer team game. Problem: Each player has a 1 to 5 star rating
Setting: A pseudo-random pattern has to be generated. There are several ways / or
After setting up TemplaVoila like ever i end up in this view. I set
I have been having intermittent issues on some servers running Archlinux / php-fpm 5.3.9
Setting up a Samba share has got to be one of the most complex
Setting the src attribute of an IFrame to data:application/pdf;base64, isn't working for me, any
Setting up a simple grails app with Dojo, i used the grails install-plugin dojo

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.