I want a PHP script to run on form submit and use Ajax to stop the page refreshing.
The JavaScript code successfully reaches the .done method and I put a console.log into the first line of my php script which doesn't seem to be getting triggered.
JS
$('.enquire-form').submit(function(e) {
e.preventDefault();
$this = $(this);
$.ajax({
type: "POST",
url: "post.php",
data: $this.serialize()
}).done(function(data) {
alert("done");
}).fail(function( jqXHR, textStatus ) {
console.log("Request failed: " + textStatus);
alert( "Request failed: " + textStatus );
});
});
PHP (originally it was console.log but have changed based on suggestions)
echo "hello world";
Folder directory (enquiry.html has the form in it)
Thanks :)