I load a second page with ajax and want to append a specific id from that page onto the current page.
function Content() {
$("ul.tabs li a").click(function() {
$.ajax({
url: $(this).attr('href'),
success: function(response) {
$(response).find('ul#image-gallery-items').appendTo('ul#image-gallery-items');
}
});
return false;
})
}
what am I missing?
You can also load page fragments with jQuery load
function:
$("ul.tabs li a").click(function() {
$('#image-gallery-items').load(this.href + ' #image-gallery-items');
return false;
})
In this case to append elements you can use:
$("ul.tabs li a").click(function() {
$('<div></div>').load(this.href + ' #image-gallery-items').children().appendTo('#image-gallery-items');
return false;
})