Jquery ajax returning 404 not found
It seemed to be a problem with the FormData
object. Once I changed my method to use .serialize()
instead, the page worked just fine.
$("form#applyform").submit(function(){
var data = $("form#applyform").serialize();
jQuery.each($('#file')[0].files, function(i, file) {
data.append('file-'+i, file);
});
$.ajax({
url: 'ValidateApplication.php',
data: data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function(data){
alert(data);
}
});
}
I've had the same issue and after 2 hours looking for what was causing the 404 Not Found error I found that I was recently playing with the header()
from PHP and had forgotten to delete the following line of code:
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
After deleting it, my Ajax functions became normal again.
For me, it was that I used an input field with name="name"
which made the called page return a 404. Weird stuff, hope this helps someone.