Why Can't I Parse A Ajax Html Get Response In Jquery?
I'm tempering with a Chrome Extension where I use an Ajax-request to get HTML from a requested URL. This works, but I want to get all the text values some certain elements. By exa
Solution 1:
If you are using jquery 1.9, do:
...
success: function(data) {
var html = $.parseHTML(data);
console.log($(html).find( '.heading_bold' ).text());
}
..
Because as per jQuery 1.9:: HTML strings passed to jQuery() that start with something other than a less-than character will be interpreted as a selector. Since the string usually cannot be interpreted as a selector, the most likely result will be an "invalid selector syntax" error thrown by the Sizzle selector engine. Use jQuery.parseHTML() to parse arbitrary HTML.
Post a Comment for "Why Can't I Parse A Ajax Html Get Response In Jquery?"