Let's say I have this page (page.html):
<html>
<body>
<h1>AAA</h1>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$.get('page2.html', function(data){
// I want to replace the entire HTML with the HTML of page2.html
// but this doesnt' work
$('html').replaceWith(data);
});
}); //]]>
</script>
</body>
</html>
Another page (page2.html):
<html>
<body>
<h1>BBB</h1>
</body>
</html>
As you can see in my code snippet, I would like to fetch HTML from the page2.html and replace the entire content of page.html with the fetched response.
How to do that?