I asked at Parsing HTML String with jQuery how I can use jQuery on an html string. That all works, but when I apply it to ajax - it does not work. Here is the code.
Try:
html = $("div", code);
html.each(function() {
alert($(this).html());
});
The reason you can't do it the way you have it, is because when parsing HTML jQuery wants to have a single root element. If it doesn't then you have to do it the way above. The following HTML/JS would also work:
var html = $(code);
html.children().each(....);
zebra
bar