Reputation: 11210
I need to remove an element with the class .connectNow
from the data returned with the following ajax call:
$.ajax({
type: 'get',
url: pages[i] +'.php',
data: 'ajax=1',
success: function(txt) {
// the following line is not operating as expected
$(txt).find('.connectNow').remove();
$('.slide').eq(0).after('<div class="slide">' + txt + '</div>');
$('.slide').animate({'left':'-=425px'},1500);
}
});
I've looked at (and tried) the following, none of which seem to help in my situation, unless I'm implementing them wrong.
Upvotes: 1
Views: 141
Reputation: 191729
A working version (using fake input xml):
Some of the seemingly strange choices made are explained with inline comments.
Upvotes: 1
Reputation: 18233
You should set the data type of your returned ajax to be html (it may be defaulting to text, though jQuery is supposed to guess what it is).
If that doesn't work though here is a little hack which may help you
txt = $('<div/>').append(txt).find('.connectNow').remove().end().html();
Upvotes: 0