I'm requesting the wordpress function if (email_exists($email)) { ... }
from a file (email_check.php) via ajax. Using this function is causing a server error though.
The origin (from an input text field):
var check = $('#email-input'); var email = check.val(); $.ajax({ url: "email_check.php", data: {'email' : email}, type: "GET", dataType: 'json', success: function(data) { if(data.result) { alert('Email exists!'); } else { alert('Email doesnt!'); } }, error: function(data){ //error } });
check_email.php
$email = $_GET['email']; if ( email_exists($email) ) {$response->result = true;} else {$response->result = false;} echo json_encode($response);
This results in no alert taking place. By going directly to [email protected]
it give me a server error page. I also replaced email_exists($email)
with the same direct email entered as the url param and it does work.
Does anyone know why this is?