Directory problem in XAMPP

Asked

Viewed 68 times

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.

  • The email.php must be in the project root. Probably in the same folder as the index.html. You already tested that?

  • It worked, the only strange thing is that PHP runs normal, but AJAX does not trigger the parameter Success

  • 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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.