Я устал сделать это с помощью цикла, но он копирует каждые данные в обоих контенте. /> html: < /strong> < /p>
Код: Выделить всё
Код: Выделить всё
$(".data").each(function() {
var path = $(this).attr("data-xml");
$.ajax({
url: path,
dataType: "xml",
success: parse,
error: function() {
alert("Error: Something went wrong with loading the playlist!");
}
});
});
function parse(document) {
$(document).find("person").each(function() {
$(".data").append(
"Name: " +
$(document).find("name").text() +
"Title: " +
$(document).find("title").text() + "")
//$(document).find("name").text();
});
}
Код: Выделить всё
$(".data").each(function() {
// store element instance
var elem = $(this);
var path = $(this).attr("data-xml");
//console.log($el);
$.ajax({
url: path,
dataType: "xml",
success: function(xml){
parse(document, elem);
},
error: function() {
alert("Error: Something went wrong with loading the playlist!");
}
});
});
function parse(document, elem) {
console.log($(document).find("name").text());
$(document).find("person").each(function() {
//alert($el);
var $person = $(this);
elem.append(
"Name: " +
$person.find("name").text() +
"Title: " +
$person.find("title").text() + "")
});
}
Подробнее здесь: https://stackoverflow.com/questions/350 ... ml-data-in
Мобильная версия