ajax get an div outside a form
Hello,
We encounter a strange issue.
Having a html response like this:
- <html>
- <body>
- <div id="mydiv">content</div>
- </body>
- </html>
Doing :
- alert($('#mydiv').text());
gives me "content"
Doing :
- $.get([url-to-the-page]),
- {},
- function(data) {
- alert(data); //shows all the html (see above)
- alert($(data).find('#mydiv')); // SHOWS NOTHING !!!
- }
- );
To get the correct result ("content"), i have to put the div into a form :
- <html>
- <body>
- <form><div id="mydiv">content</div></form>
- </body>
- </html>
I don't know why.
Thanks a lot.
Thieum.