carica.html
codice:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento senza titolo</title>
<script type="text/javascript" src="filejavascript.js"></script>
</head>
<body onload="StampaId()">
<fieldset>
<legend>Caricamento nuovo prodotto:</legend>
<table>
<tr>
<td>
ID
</td>
<td>
<p><div id="divId" > </div>
</td>
</tr>
</table>
</fieldset>
</body>
</html>
filejavascript.js
codice:
function StampaId()
{
if(window.XMLHttpRequest)
xmlHttp=new XMLHttpRequest();
if (!xmlHttp)
alert("errore durante la creazione dell'oggetto XMLHttpRequest.");
name=myname.value;
xmlHttp.open("GET", "stampaId.php", true);
xmlHttp.onreadystatechange=handleRequestStateChange();
xmlHttp.send(null);
}
function handleRequestStateChange()
{
response=xmlHttp.responseText;
document.getElementById("divId").innerHTML= response;
}
Perche non funziona? il file php funziona perfettamente, solo non compare niente nel campo div!! Dovrebbe essere un errore nel javascript forse nel onload="StampaId()"
Idee??