Carregando página de um menu dentro da DIV
Gostaria da ajuda de vocês pra me dizer o que está errado neste código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="ajax.js" type="text/javascript" />
<script language="javascript" type="text/javascript">
function caller(n){
switch(n){
case 0: t="pagina1.html"; break;
case 1: t="pagina2.html"; break;
case 2: t="pagina3.html"; break;
case 3: t="pagina4.html"; break;
}
if(navigator.appName == "Microsoft Internet Explorer"){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
xmlHttp = new XMLHttpRequest();
}
if(xmlHttp.readyState == 4){
document.getElementById('centro').innerHTML = xmlHttp.responseText;
}
xmlHttp.open("GET", t, true);
xmlHttp.send(null);
}
</script>
</head>
<body>
<ul>
<li><a href="javascript:caller(0)">Página 1</a></li>
<li><a href="javascript:caller(1)">Página 2</a></li>
<li><a href="javascript:caller(2)">Página 3</a></li>
<li><a href="javascript:caller(3)">Página 4</a></li>
</ul>
<br />
<br />
<div id="centro" style="float:left; width:500px; min-height:400px;"></div>
</body>
</html>
A idéia é que ao clicar no link, ele carregue a página que foi selecionada, mas ele não faz nada.
Desde já agradeço a atenção!
Discussão (5)
Carregando comentários...