I have this code with load:
$('#single-photo-zoom').load(href+' #content', function() {
alert("ok");
});
I want to use $.ajax, but I don’t know how to load #content in #single-photo-zoom
xhr = $.ajax({
url: href,
success: function(data) {
// ???
}
});
I would like to use $.ajax because I want to have the possibility to abort loading. And it’s not possible with load function.
First turn data into a jQuery object, then can retrieve the content you want from that object and insert in appropriate element:
EDIT:
assumes that
#contentis in another parent likebodyor anotherdiv. If not a full page and#contentis at root level usefilter()instead offind()