Questo non affrontare il problema esatto, ma 'Dark Side of the Carton' ha alcuni eccellenti codice per la convalida reCAPTCHA tramite jQuery AJAX che potrebbe aiutare.
In sintesi:
Aggiungere il seguente JavaScript:
$(function() {
function validateCaptcha() {
var challengeField = $('input#recaptcha_challenge_field').val(),
responseField = $('input#recaptcha_response_field').val();
// alert(challengeField);
// alert(responseField);
// return false;
var html = $.ajax({
type: 'POST',
url: 'ajax.recaptcha.php',
data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
async: false
}).responseText;
if (html.replace(/^\s+|\s+$/, '') == "success") {
$('#captchaStatus').html(' ');
// Uncomment the following line in your application
return true;
} else {
$('#captchaStatus').html(
'Your captcha is incorrect. Please try again'
);
Recaptcha.reload();
return false;
}
}
// Modified as per comments in site to handle event unobtrusively
$('#signup').submit(function() {
return validateCaptcha();
});
});
quindi aggiungere il file ajax.recaptcha.php che: "uscite solo la parola‘successo’se il captcha corrisponde ed un messaggio e la risposta di reCaptchta in caso di esito negativo, è importante perché stiamo cercando la parola successo nella nostra funzione validateCaptcha(). "
require_once('/inc/recaptchalib.php');
$publickey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'; // you got this from the signup page
$privatekey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$resp = recaptcha_check_answer(
$privatekey,
$_SERVER['REMOTE_ADDR'],
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']
);
if ($resp->is_valid) {
?>success< ?
} else {
die(
"The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")"
);
}
L'esempio è in PHP, ma mi adatto facilmente per lavorare con Zope/Python
fonte
2009-11-05 14:00:19
Avete mai trovato una soluzione per questo? Sto vivendo esattamente lo stesso problema ... Grazie. –