I temper with the Chrome extension, where I use an Ajax request to retrieve HTML code from the requested URL. This works, but I want to get all the text values for some specific elements. For example, everything with the script.js class.heading-bold
$.ajax({
url: "http://page.com/page.html",
type: "GET",
dataType: "html",
success: function(data) {
console.log($(data).filter( '.heading_bold' ).text());
}
});
HTML response
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Beerpong</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
</head>
<body>
<div id="table-container">
<table>
<tbody>
<tr>
<td><div class="heading_bold">Beerpong</div></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Logging in to the console works fine. This is my conclusion:
Uncaught Error: Syntax error, unrecognized expression: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0....
Why? Why is this not just console.log my desired values?
source
share