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;
}
ここで、変数を recpatchaverify.php に渡しました
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";
}
私の問題は、Recaptcha を正しく入力するたびに html 変数に「accept」と表示されることですが、IF ステートメントでは機能しませんか?