I have explained how to use Google reCAPTCHA in another post. Google returns “true” or “false” in “success” parameter as a response to your AJAX call.
After your implementation, you might be constantly getting “false” value in this parameter. The response looks like this in your browser trace:
{
“success”: false,
“error-codes”: [
“missing-input-response”,
“missing-input-secret”
]
}
Issue
You might be sending “secret” and “response” parameters as hash map. Your code may look like this:
$.ajax({ type: "POST", url: "https://www.google.com/recaptcha/api/siteverify", data: { secret: "YOUR-SECRET-KEY", response: captchaResult }, contentType: "application/json; charset=utf-8", dataType: "json", failure: function (response) { alert(response.d); }, success: function (response) { googleCallResult = response.success; } }).done(function () { // Do stuff with googleCallResult });
Solution
Google reCAPTCHA expects parameters to be sent in the URL instead of hash map. So you need to add “secret” and “response” parameters into the URL. Here is the edited code:
$.ajax({ type: "POST", url: "https://www.google.com/recaptcha/api/siteverify?secret=YOUR-SITE-KEY&response=" + captchaResult, contentType: "application/json; charset=utf-8", dataType: "json", failure: function (response) { alert(response.d); }, success: function (response) { googleCallResult = response.success; } }).done(function () { // Do stuff with googleCallResult });
YOU ARE A GENIUS!
ive been on this for like 2 days trying to sent it as parameters
thank you
Thank you! This problem has been driving me nuts! All sorted now thanks to you.
Hi i have multiple recaptcha in single page. its working only for one captcha other captcha reponse is false. what i am missing?