Hi--
I am trying to do a very simple test implementation by creating an automatically rendered recaptcha widget, and then verifying the response via client-side javascript when the user clicks a button.
Because I'm using the automatic rendering for a recaptcha widget, I don't bother to get/save the widget ID. According to the documentation, when I try to verify the response with getrecaptcha.getResponse(), the widget ID is optional--if I don't provide one, it will automatically identify the first widget created (I only have one).
But this is not working. When I call the getResponse function, I am expecting a JSON object of the result...but instead, the result is undefined (I get an exception that says the widget ID is invalid).
Has anyone gotten this to work?
Here's my HTML code to automatically render the widget:
<div class="g-recaptcha" data-sitekey="alongstringofrandomcharacters"></div>
And here's my script to check the response:
function showValidation() {
var r;
r = grecaptcha.getResponse();
alert(r.success);
}
Instead of displaying "true" or "false", I get "undefined".