At the click of a singer class button, the name of the singer and buttons with music class with their respective song names (data) are returned. When clicking on a music class button, the song lyrics (data2) is returned, at this point I would like to add a button to activate the first ajax (singer class) to relate the singer and his respective songs again. I made an attempt to return a singer class button on data2 but it doesn't work. Is there any way to perform this operation?.
$('.singer').click(function() {
$th = $(this);
$.ajax({
url: "page1.php",
type: 'GET',
data: {
singer: $th.attr("title")
},
success: function(data) {
$("#result").html(data);
$('.music').click(function() {
$thm = $(this);
$.ajax({
url: "page2.php",
type: 'GET',
data: {
identificador: $thm.attr("title")
},
success: function(data2) {
/*########### For example, in data2 return too
<button class="singer" title="Madona">Madona</button>
but it doesn't work
###### */
$("#result").html(data2);
},
error: function() {
$("#result").html("error");
}
}); //ajax
});
},
error: function() {
$("#result").html("Error");
}
}); //ajax
});