2
recaptcha 입력의 유효성을 검사하는 데 문제가 있습니다. Heres는 내 코드 :Ajax 오류가있는 Recaptcha
// Validate Recaptcha Input
var challenge = $("#recaptcha_challenge_field").val();
var response = $("#recaptcha_response_field").val();
var dataString = 'recaptcha_challenge_field=' + challenge + '&recaptcha_response_field=' + response;
var html = $.ajax({
type: "POST",
url: "PHP/recaptchaverify.php",
data: dataString,
async: true
}).responseText;
console.log(html);
if(html == 'accept')
{
alert("CORRECT");
}
else
{
alert("The reCAPTCHA wasn't entered correctly. Go back and try it again.");
$("#recaptcha_response_field").focus();
Recaptcha.reload();
return false;
}
지금 나는 지금
require_once('../scripts/recaptcha-php/recaptchalib.php');
$privatekey = "MYKEY";
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid)
{
// What happens when the CAPTCHA was entered incorrectly
echo "error";
}
else
{
// Your code here to handle a successful verification
echo "accept";
}
내 문제는 HTML 변수 내가 제대로 reCAPTCHA를 입력 할 때마다 "동의 함"을 표시하고있다 recpatchaverify.php 내 변수를 전달하지만, '수상 IF 문에서 작동합니까?
당신이 수정 .responseText받을 수 있나요? – Jai
예, .responseText가 오류를 표시하고 변수를 올바르게 승인합니다. 그냥 if else 문을 지나치는 것입니다. – Brandon
if (html == "accept") <<<가 작동하지 않습니다. – Brandon