0

Possible Duplicate:
jquery ajax parse response text

Given I have an complete HTML document stored as a string (loaded using Ajax for example) I can't seem to filter it.

// data.responseText returned by an Ajax call contains a complete HTML page

$(data.responseText).filter('.someclass').each(function(){
    console.log( $(this).html() );
});

This produces nothing, and there certainly is a .someclass in the loaded HTML string. If I try .filter('div'), it only produces two despite there being many, many <div> elements in the string.

I thought I found a question asked here that was exactly this (with an answer that worked) and have since refactored some code, losing the changes (they weren't critical at the time) but now I'd like to incorporate it again.

Is there anything in an HTML string (DOCTYPE declaration, comments, etc.) that could possibly trip up the .filter() method?

Community
  • 1
  • 1
Dan Lugg
  • 20,192
  • 19
  • 110
  • 174

0 Answers0