New validation with jQuery doesn't send tha value

Clash Royale CLAN TAG#URR8PPP
New validation with jQuery doesn't send tha value
I want to make double verification to Emails, first verify is email is accepted ( is not an incorrect mail like gimil.com homail.com ... etc)
and second verification to know if email is existed,
I try to do with this code jQuery
$('#signup').validate(
errorElement: 'span',
rules:
Email:
required: true,
email: true,
remote:
url: '/verifiyEmail',
type: 'POST', //Or whatever
data: function()
return $("#email").val(); // The value of the email field
,
dataType: "JSON",
dataFilter: function(responseData)
alert(responseData.message); // Or whatever
return responseData.isValid; // validation result
);
and the PHP code
if(isset($_POST['email']))
$email = $_POST['email'];
$response = null;
$isInBlackList = Member::Accepted($email);
if($isBlackList)
// User is in the blacklist
$response = array("isValid"=>false, "message"=>"This email is blacklisted!"); // Initialize $response
else
$alreadyExists = ! Member::($email); // You have to implement this.
if(!$alreadyExists)
// Email already exists
$response = array("isValid"=>false, "message"=>"This email is already in user"); // Initialize $response
else
// We found a valid email
$response = array("isValid"=>true);
header('Content-Type: application/json');
echo json_encode($response);
else
$response = array("isValid"=>'error');
header('Content-Type: application/json');
echo json_encode($response);
And always the response is error, that mean the Email is doesn't send to PHP code
error
is there any solution?
@MarkBaijens how can I do it sir ?
– PHPSA
Aug 8 at 11:35
data: email: $("#email").val() – Mark Baijens
Aug 8 at 11:36
data: email: $("#email").val()
@PHPSA try using
console.log(responseData); first.See the result and than try further debugging.– Nishant Dongare
Aug 8 at 11:56
console.log(responseData);
@NishantDongare I use the
console.log and I found the first error ( no data sending ) the php code, email doesn't send– PHPSA
Aug 8 at 12:15
console.log
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You send a function in data. Php can not execute javascript functions. You need to send an actual value.
– Mark Baijens
Aug 8 at 11:33