Ciao ragazzi sono alle prime armi con ajax mentre su php ho un po di esperienza....
Stavo provando ad implementare un po di ajax per gestire il refresh localizzato di parti di pagine....
il codiche che ho scritto prendendo spunto da vari esempi in rete è questo ma non funge.... Come mai??
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
<title> - PhpMyPanel -</title>
<link rel="stylesheet" type="text/css" href="css/mainStyle.css" />
<?php include("functions/actions.php"); ?>
<?php include("config.php"); ?>
<script language="javascript">
var myRequest = null;
function CreateXmlHttpReq(handler) {
var xmlhttp = null;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = handler;
return xmlhttp;
}
function myHandler(id) {
if (myRequest.readyState == 4 && myRequest.status == 200) {
var e = document.getElementById(id);
e.innerHTML = myRequest.responseText;
alert("Eseguito");
}
else
alert("Error!!");
}
function printPage(page,id) {
myRequest = CreateXmlHttpReq(myHandler(id));
myRequest.open("GET",page);
myRequest.send(null);
}
function init(){
printPage("header.pmp","header");
printPage("menu.php","menu");
printPage("main.pmp","main");
printPage("footer.pmp","footer");
}
</script>
</head>
<body>
<?php $cwd=$cwd1=getcwd(); ?>
<div id="content">
<div id="header">
</div>
<div id="body">
<div id="menu">
</div>
<div id="main">
</div>
</div>
<div id="footer">
</div>
</div>
<div id="end">:-) MainTux</div>
<script language="javascript">init();</script>
</body>
</html>
P.S. Scusate per l'indentazione ... non scrivo così....

