Im trying to submit a form using ajax to call the php file, but when I try to test it, the browser console prints the following error
Below is my ajax post code
$( document ).ready(function() {
$("form").submit(function(e) {
e.preventDefault(); // prevent page refresh
var email = $("#email").val();
if (validateEmail(email)) {
$.ajax({
type: "POST",
url: "php/send_form.php",
data: $(this).serialize(), // serialize form data
success: function(data) {
document.getElementById("successfullySentForm").style.display = "block";
},
error: function() {
document.getElementById("genericError").style.display = "block";
}
});
} else {
document.getElementById("wrongEmailFormat").style.display = "block";
}
});
});
Im running this website in my webserver.
Use $_SERVER['DOCUMENT_ROOT'] to solve path related problems.
Example: $_SERVER['DOCUMENT_ROOT'].'/path/to/file';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.