Salve a tutti, dovrei passare con uno script ajax dei valori presi da una form e farli elaborare da una pagina php.
codice:
function getXMLHttp()
{
var xmlHttp
try
{
//Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
//Internet Explorer
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
alert("Il tuo browser non supporta AJAX!")
return false;
}
}
}
return xmlHttp;
}
function MakeRequest()
{
var xmlHttp = getXMLHttp();
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
HandleResponse(xmlHttp.responseText);
}
}
xmlHttp.open("POST", "invia.php", true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send("nome=&nome_amico=&mail_amico= ");
}
function HandleResponse(response)
{
document.getElementById('ResponseDiv').innerHTML = response;
}
Non riesco a farlo funzionare. Se posto invece normalmente il form funziona, quindi presumo che non riesco a passare i dati tramite ajax. qualcuno può darmi una mano? Grazie in anticipo.