ウェブサイトのサイクリングクォートを設定しています。JQUERY html()またはappend()を使用して初めて使用した後にXMLデータにアクセスできない
私は、一連のデータでXMLファイルを設定しました。データには、見積り、著者、著者の役職(見積り、著者、タイトル)が含まれます。
次に、jQuery .ajaxコールがあり、それを変数xmlData
に格納します。
xmlDataは、指定されたidタグにhtmlを追加または追加するために使用されます。
私はxmlデータを移動するためにsetInterval()を使用しています。
アイデアはループのようにそれを通過することです:1 | 2 | 3 | 1 | 2 | 3など。しかし、データがIDに追加された後に戻ってくると、それはもう表示されません。データがXMLファイルから削除されたかのようです。
ご協力いただければ幸いです。コードは、私がテストに取り組んでいるウェブサイトのURLとともに、下にあります。ここで
<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>
は、ウェブサイトである:http://privilegeofpersecution.com/wp-content/themes/privilegeofpersecution/xmltest.html