I tested JQuery, I have an html response coming from an AJAX request, so initially the result would be like this.
<!DOCTYPE html> <html> <body> <div id="dashboard"> <div id="dash2"> <h1>Hi</h1> </div> </div> </body> </html>
In my Ajax success code this is ..
success : function(response,status) { console.log( $(response).find('#dashboard').html() ); }
After printing to the console, which gives me undefined .
However, when I change the response page (I created a nesting div) to this
<!DOCTYPE html> <html> <body> <div id="div1"> <div id="dashboard"> <div id="dash2"> <h1>Hi</h1> </div> </div> </div> </body> </html>
The line from my Ajax success code returned console.log( $(response).find('#dashboard').html() ); returned
<div id="dash2"> <h1>Hi</h1> </div>
My question is. How did the first HTML appear when executing console.log( $(response).find('#dashboard').html() ); , he gave me undefined, however on the second HTML (the one that is embedded in the div) gave me the contents of #dashboard (which is the one I expect to receive.
source share