I am loading an html page within the body of a landing page via jquery and ajax. I need the <title>Page Title</title>
from the loaded document for the landing page.
I have tried this, but no luck:
$.ajax({
url: "test.htm",
cache: false,
dataType: "html",
success: function(html){
$('#main-load').html(html);
$('#greeting').append($(html).find('title').text());
}
});
I have also tried a few other methods, but no luck. Any ideas?
Thank you!
EDIT: test.htm is a very simple document.
Example:
<html>
<head>
<title>Page Title</title>
<style>
....
</style>
</head>
<body>
....
</body>
</html>
html
method will strip the head from the document before it inserts it. This is necessary to avoid breaking. Not sure what a good workaround would be - you may have to parse the raw data – Pekka Apr 13 '11 at 14:27