undefined is not a function when calling grecaptcha.getResponseHeader()

1,230 views
Skip to first unread message

Geoff Swartz

unread,
Dec 3, 2014, 1:29:43 PM12/3/14
to reca...@googlegroups.com
I have the following (simplified) .net code set up based on what I was able to glean from the documentation.

<html>
<head>
    <script type="text/javascript">
        var captcha;

        var onloadCallback = function () {

            captcha = grecaptcha.render('dvCaptcha', {
                'sitekey': '<%=WebConstants.GoogleSiteKey %>',
                'theme': 'light'
            });
        };

        function VerifyCaptcha() {
            console.log(grecaptcha.getResponseHeader(captcha));
            return false;
        }
    </script>
</head>

<body>
<form id="form1" runat="server">
<div id="dvCaptcha"></div>
 <asp:Button ID="btnSubmit" runat="server" Text="submit" OnClick="btnSubmit_Click" OnClientClick="return VerifyCaptcha();" />
</form>
</body>
</html>

When I click the button which calls the VerifyCaptcha function I get "undefined is not a function" and it's pointing to what I'm assuming is the google injected code line 2

with (__commandLineAPI || { __proto__: null }) {
grecaptcha.getResponseHeader()
}

Does anyone see what I might be doing wrong with my code?  Thanks.

Geoff Swartz

unread,
Dec 3, 2014, 1:43:47 PM12/3/14
to reca...@googlegroups.com
I guess it would have been better if I had actually called the right method on the grecaptcha.  It should have been getResponse, not getResponseHeader.  Not sure where Header came from.
Reply all
Reply to author
Forward
0 new messages