[Violation] 'submit' handler took 3501ms jquery.min.js:2
GET http://localhost/oramexhomes/backend/index.php 404 (Not Found)
I get these two errors in my console.log when i try to post data using query ajax post to my php file.
my folder structure is oramexhomes/index.php for my index page and all frontend pages and codes for my backend codes and files = oramexhomes/backend/authController.php I am trying to post using jquery/ajax to backend
<script>
$("#agentregistration").submit(function(esignup){
esignup.preventDefault();
validatesurname();
validatefirstname();
validatephonenumber();
if (
surnameError == true &&
firstnameError == true &&
phonenumberError == true &&
emailError == true
) {
$.ajax({
type: "POST",
url: "backend/authController.php",
data: $("#agentregistration").serialize(),
dataType : "json",
success : function(response){
console.log(response);
if(response.status){
toastr.success(response.message);
$('#agentregistration')[0].reset();
$('#registrationmodel').modal('hide');
}else {
toastr.error(response.message);
}
}
});
return true;
}
});
</script>
oramexhomes/backend/authController.php
if (isset($_POST['agentform'])) {
$surname = $_POST['surname'];
$firstname = $_POST['firstname'];
if (strlen($surname) < 1) {
$_SESSION['error'] = "Please, add surname";
header("Location:index.php");
return;
}
if (strlen($firstname) < 1) {
$_SESSION['error'] = '<div class="alert alert-danger">"Please, add your first name"</div>';
header("Location:index.php");
return;
}
$sql = "INSERT INTO agent (agent_id, Surname, First_name, Other_names, Email, Password, Phone_number, Refeeral_id, verified, token)
VALUES (:agentid, :surname, :firstname, :othernames, :email, :password, :phonenumber, :refeeralid, :verified, :token)";
$stmt = $pdo->prepare($sql);
$stmt->execute(array(
':agentid' => $agentid,
':surname' => $_POST['surname'],
$success = '<div class="alert alert-success"> Thank you for registering with Oramex Property. To continue, please sign in to your email account and click on
the verification link we just emailed you at <strong>'.$_SESSION['email'].'</strong></div>';
$response = array('status' => true, 'message' => $success);
header("Location:index.php");
return;
}else
{
$response = array('status' => false, 'message' => $_SESSION['error']);
}
echo json_encode($response);
}
- I expect at least console.log to give me list of data that is posted but it doesnt.
- data is not inserted in the database.
- before toastr.error shows message from severside but now it does not.