jQuery load a page and add only body part in my current page
I'm trying to use both $.ajax or .load() functions to load a page by ajax
and than add its content replacing my current $('body').html(). The
problem is than when I try to do it jquery will add everything (included
the content of <head></head> in my body).
$.ajax({
type: 'GET',
url: '/somepage.html',
success: function(data) {
$('body').html(data);
}
});
or
$('body').load('/somepage.html');
The result will be something like
<body>
<-- Here starts the content of the head -->
<title>....</title>
<script src="..."></script>
<link src="..."></link>
<meta></meta>
<-- Here ends the content of the head -->
<-- Here starts the real body content -->
<div>........</div>
<-- Here ends the body content -->
</body>
How can I avoid this? Am I doing something wrong?
No comments:
Post a Comment