I have a problem sending form data through Ajax to a PHP script. When sending data I get this type of error.
Serious error: Libs Controller class not found
I have written my own MVC project structure and it is working well if I send data only with POST request but when I send with AJAX this error appears
use Libs Controller;
use PHPMailer PHPMailer PHPMailer;
use PHPMailer PHPMailer Exception;
Contact class extends the Controller {
// rest code to send an email with PHPMailer
}
And here is the script js
$ ("# contact form"). in (& # 39; send & # 39 ;, function (e) {
$ (". validmessage"). css ("display", "block");
e.preventDefault ();
$ .ajax ({
url: "/../../app/controllers/Contact.php",
type: "POST",
data: $ (this) .serialize (),
success: function (data) {
$ ("# form_output"). html (data);
}
error: function (jXHR, textStatus, errorThrown) {
alert (errorThrown);
}
});
});