I have a form and one of the fields is an email with id email and after the user inputs their email and clicks outside the field, I wish to get the value of the email and then use ajax to pass that value to another php file that will run a wordpress function called email_exists() and then pass that result back to ajax. Right now I just want to console log the result value and then later I will add additinal jquery to alert the user in the form.
I have my current code below and it is not showing anything in the console even if I put an email that does exist on my wordpress site and I can't figure out why. Any help would be great, thanks!
employees.php
<script>
$(function() {
$("#email").blur(function () {
var email = $(this).val();
url: 'validation.php',
type: ' POST',
data: {
email: email
},
success: function(response) {
console.log("response");
},
error: function(response) {
console.log("response");
}
});
});
<script>
validation.php
<?php
$response = email_exists($_POST['email']);
echo $response;
?>