I have one Spring MVC project, where the first page after the login is the following (each one of the links below are mapped by DispatcherServlet):
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>HorarioLivre</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/style-main.css">
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<header>
<div class="container">
<h1><a href="index.html">HorarioLivre</a></h1>
<nav>
<ul>
<li><a href="listagem_evento.html" rel="gb_page_fs[]" class="icon evento">Eventos</a></li>
<li><a href="cadastra_horario.html" class="icon horario">Cadastrar Horarios</a></li>
<li><a href="listagem_horario.html" class="icon horario">Listar Horarios</a></li>
<li><a href="listagem_usuario.html" class="icon usuario">Usuarios</a></li>
<li><a href="#">${usuario.nome}</a>
<ul class="submenu">
<li><a href="usuario_perfil.html" class="icon perfil">Perfil</a></li>
<li><a href="usuario_config.html" class="icon settings">Configurações</a></li>
<li><a href="usuario_logoff.html" class="icon logout">Sair</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</header>
<section class="about">
</section>
</body>
</html>
My question is: Is there any way to display the content of the pages linked from this page (in the section identified by 'class=container', in the other section identified by 'class=about', using javascript? I want with this load the content without need load the entire page.
UPDATE 1
Following the example from here, I did three changes in my code. The links in the div 'container' was changed to:
<a href="#" onclick="loadpage('listagem_evento.html')" class="icon evento">
Add the id to the tag:
<section class="about">
<div id="result">
</div>
</section>
And I add this Javascript code:
<script>
function httpGet(theUrl)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
createDiv(xmlhttp.responseText);
}
}
xmlhttp.open("GET", theUrl, false);
xmlhttp.send();
}
function createDiv(responsetext)
{
var _body = document.getElementsById('result');
_body.innerHTML = responsetext;
}
function loadpage(url)
{
var result = httpGet(url);
createDiv(result);
}
</script>
But now when I click in the link, nothing happens. What I made wrong?