I'm just doing a simple ajax request to get the content of a file, but when I try to grab the actual <body>
it always returns nothing.
jQuery.ajax(location).done(function(response) {
// RETURNS []
console.log(jQuery(response).find('body'));
// <body class="html ...">
// RETURNS []
console.log(jQuery(response).find('.html'));
// When I try to get any other div it just works
// RETURNS THE DIV
console.log(jQuery(response).find('#header'));
})
jQuery(response) strips away the html, head and body tags
you need to wrap your body content in an extra div and look for it.
edit:
jQuery(string) parse the string to check if it is a selector or a html fragment. if it's a html fragment the string is injected into an empty div which do not support html, head and body tags hence they are stripped away.