¿Por qué los guiones ajax y php no se vuelven a publicar en su forma original?

Tengo este formulario y estoy usando ajax para enviar datos a un script php simple (solo para resolver problemas con script php simple) pero no está publicando datos en formato html original … aquí están los dos scripts contact.html

       Contact Us         function validateForm() { var message = ""; var letters = /^[A-Za-z]+$/; //do validation var jname = document.forms["myForm"]["name"].value; var jemail = document.forms["myForm"]["email"].value; var jsubject = document.forms["myForm"]["subject"].value; var jtext = document.forms["myForm"]["text"].value; var joutputMsg = ""; //checking for empty fields if (jname == null || jname == "") { message += "name field empty!\n"; } if (jname != "" && !jname.match(letters)) { message += "Invalid name: only letters allowed!\n"; } if (jemail == null || jemail == "") { message += "email field is empty!\n"; } if (jsubject == null || jsubject == "") { message += "Subject field is empty!\n"; } if (jtext == null || jtext == "") { message += "Text field is empty!\n"; } if (message != "" ) { alert(message); return false; } //send data to php form---------------------> // create the XMLHttpRequest object, according browser // create the variable that will contain the instance of the XMLHttpRequest object (initially with null value) var xmlHttp = null; if(window.XMLHttpRequest) { // for Forefox, IE7+, Opera, Safari, ... xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { // for Internet Explorer 5 or 6 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } // sends data to a php file, via POST, and displays the received answer // create pairs index=value with data that must be sent to server var parameters="name="+jname+"&email="+jemail; request.open("POST", "contact.php", true); // set the request // adds a header to tell the PHP script to recognize the data as is sent via POST request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.send(the_data); // calls the send() method with datas as parameter // Check request status // If the response is received completely, will be transferred to the HTML tag with tagID request.onreadystatechange = function() { if (request.readyState == 4) { document.getElementById("output-data").innerHTML = request.responseText; } } return false; }    

Contact Us

aldkfjasdkfjaskdfasdfkasdkfjadsfjsdkfjaskfjasdkfjasjfaskdfjsdkfjsksdsdkjsd

GOOGLE MAP HERE!

<!-- -->

contact.php

 <?php if (isset($_POST['name'])) { $name = $_POST['name']; } if (isset($_POST['email'])) { $email = $_POST['email']; } echo "Name: " . $name . "
Email: " . $email; ?>

Hay tantos errores pero lo tengo funcionando, es posible que desee ver la convención de nomenclatura en sus campos de entrada. Por ejemplo, en nombre tienes el id de id="inputEmail13" . Use la consola del navegador para ver los mensajes de error a medida que los desarrolla.

 function validateForm(event) { event.preventDefault(); var message = ""; var letters = /^[A-Za-z]+$/; //do validation var name = document.forms["myForm"]["name"].value; var email = document.forms["myForm"]["email"].value; var subject = document.forms["myForm"]["subject"].value; var text = document.forms["myForm"]["text"].value; var outputMsg = ""; //checking for empty fields if (name == null || name == "") { message += "name field empty!\n"; } if (name != "" && !name.match(letters)) { message += "Invalid name: only letters allowed!\n"; } if (email == null || email == "") { message += "email field is empty!\n"; } if (subject == null || subject == "") { message += "Subject field is empty!\n"; } if (text == null || text == "") { message += "Text field is empty!\n"; } if (message != "" ) { alert(message); return false; } //send data to php form---------------------> // create the XMLHttpRequest object, according browser // create the variable that will contain the instance of the XMLHttpRequest object (initially with null value) var xmlHttp = null; if(window.XMLHttpRequest) { // for Forefox, IE7+, Opera, Safari, ... xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { // for Internet Explorer 5 or 6 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } // sends data to a php file, via POST, and displays the received answer // create pairs index=value with data that must be sent to server var parameters="name="+name+"&email="+email; xmlHttp.open("POST", "contact.php", true); // set the request // adds a header to tell the PHP script to recognize the data as is sent via POST xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.send(parameters); // calls the send() method with datas as parameter // Check request status // If the response is received completely, will be transferred to the HTML tag with tagID xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { document.getElementById("output-data").innerHTML = xmlHttp.responseText; } } return false; } 

En el html, quiere eliminar la visibility:hidden; en la salida div

 

Editar:

La causa de la solicitud no está definida porque nunca está creando una variable llamada solicitud, pero está llamando a una.

 request.open("POST", "contact.php", true); 

Esta línea arrojará el primer error diciendo que no está definida, esto se puede arreglar fácilmente cambiando la request a xmlHttp o modificando xmlHttp = new XMLHttpRequest(); ser request = new .... mismo debería hacerse con la otra asignación xmlHttp.