I have quite an easy question but I just simply can't find out why my post isn't working. I have made a lot in the past and that's why I don't get where the error lies. Please help me, here is my AJAX code:
$(function() {
$("#btnSubmit").click(function(event) {
event.preventDefault();
var formData = $("formCI").serialize();
$.ajax({
type : "POST",
url : "formularioServer.php",
data : formData,
datatype : "json",
async : false
})
.done(function(data) {
if(data != "success"){
console.log(data);
} else {
alert("A ticket has been sent with your incident information to the CI-Hotline inbox");
window.location = "formulario.php";
console.log(data);
}
});
});
});
Parts of my HTML: <form name="formCI" id="formCI" action="formularioServer.php" method="POST" enctype="multipart/form-data" accept-charset="utf-8">
<button type="submit" name="btSubmit" id="btnSubmit" class="btn btn-default">
In the server side the POST always comes with the wrong message:
<?php
if(!empty($_POST)) {
echo "success";
} else {
echo "failed";
}
?>