Ciao a tutti.
ho un problema con ajax, vorrei fare in modo che l'invio del form sta nella stessa pafina index.php e no in thank-you.php
Ho trovato questo tutorial per imparare ma nn mi e' chiara ancora la parte su come devo mandare i valori che mi servono alla stessa pagina index.php
Vi posto il codice
Provando il codice in questo modo funziona ma ho dentro il divFormMail l'intera pagina index.php duplicate e quindi ne vedo due una al centro e l'altra dato che sta' nel div un po' spostata a destra e in basso...codice:// AJAX function GetXmlHttpObject() { if (window.XMLHttpRequest) { // IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // IE5, IE6 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } function submitFormWithAjax() { var ajaxRequest = new GetXmlHttpObject(); var checkFormSendMail = document.formSendMail.checkFormSendMail.value; var sender = document.formSendMail.sender.value; var sendTo = document.formSendMail.sendTo.value; var subject = document.formSendMail.subject.value; var textMessage = document.formSendMail.textMessage.value; var captcha = document.formSendMail.captcha.value; var parameters = "checkFormSendMail=" + checkFormSendMail + "&sender=" + sender + "&sendTo=" + sendTo + "&subject=" + subject + "&textMessage=" + textMessage + "&captcha=" + captcha; ajaxRequest.open("POST", "index.php", true); ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); ajaxRequest.send(parameters); ajaxRequest.onreadystatechange = function() { if (ajaxRequest.readyState == 4) { if (ajaxRequest.status == 200) { document.getElementById("divFormMail").innerHTML = ajaxRequest.responseText; //document.getElementById("divUploadFile").style.display = "none"; } else { document.getElementById("divFormMail").innerHTML = "An error has occured making the request"; } } else { document.getElementById("divFormMail").innerHTML = '[img]img/Loading.gif[/img] Loading Content...'; } } } // AJAX
Nn mi e' chiara sta parte
Come faccio ad usare la stessa pagina index visto che le variabili POST stanno li? thanks!!codice:ajaxRequest.onreadystatechange = function() { if (ajaxRequest.readyState == 4) { if (ajaxRequest.status == 200) { document.getElementById("divFormMail").innerHTML = ajaxRequest.responseText; //document.getElementById("divUploadFile").style.display = "none"; } else { document.getElementById("divFormMail").innerHTML = "An error has occured making the request"; } } else { document.getElementById("divFormMail").innerHTML = '[img]img/Loading.gif[/img] Loading Content...'; } }

Rispondi quotando