Files
unisa_tsw_2014_2015/ajax2.html
2014-12-07 19:33:49 +01:00

53 lines
1.0 KiB
HTML

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<p> Ciao, Simone è gay?</p>
<p id="answer"></p>
<form id="form">
<input type ="text" name="nome" placeholder="Inserisci il nome" value="" />
<input type ="text" name="cognome" placeholder="Inserisci il cognome" value=""/>
<input type ="number" name="eta" min="10" max="120" placeholder="Inserisci eta" value="" />
</form>
<br>
<span id ="data"></span>
<script>
req= new XMLHttpRequest();
req.addEventListener("load",handlerload,false);
i = document.getElementsByTagName("input");
for (k=0;k< i.length;k++)
i[k].addEventListener("input",handler,false);
function handler(e){
form = new FormData(document.getElementById("form"));
req.open("POST","ajax2.php",true);
req.send(form);
document.getElementById("answer").innerHTML = req.responseText;
}
function handlerload(e){
document.getElementById("data").innerHTML = req.responseText;
}
</script>
</body>
</html>