0
My XAMPP server (local host) has the documents of a project on /htmdocs/project , inside has a index.html what call This Javascript/Jquery Code
$(document).ready(function () {$('#emailForm').submit(function(){
$.ajax({
type: 'POST',
url: '/email.php',
async: true,
data: 'email=' + $('#campoEmail').val(),
success: function() {alert("Sucesso")}
//beforeSend: function() { alert("Enviando")}
});
});
});
HTML form
<form id="emailForm" >
<input id="campoEmail" class="input-center" placeholder="Digite aqui" type="email" name="email" required="true">
</br>
</br>
<input id="enviar" type="submit">
</form>
</div>
My doubt
What is the directory in that file email php., must be inside XAMPP to be executed when the JS file calls ?
Shows the project directory structure, in this case it should be at the root of the project.
– rray
The
email.php
must be in the project root. Probably in the same folder as theindex.html
. You already tested that?– Sergio
It worked, the only strange thing is that PHP runs normal, but AJAX does not trigger the parameter Success
– Lucas Alves
If you do not enter the Success it is because you hear an error in the request or response. use the browser tools to inspect the ajax request made.
– Juven_v