Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reCAPTCHA Ajax API + custom theme not working

Tags:

ajax

recaptcha

I can't see where I'm going wrong. I've tried everything I could think of, reCAPTCHA is just not working with the Ajax API. Here's what my code looks like:

<!-- this is in <head> -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://api.recaptcha.net/js/recaptcha_ajax.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    Recaptcha.create("my key here", "recaptcha_widget", {
        "theme": "custom",
        "lang": "en",
        "callback": function() { console.log("callback"); } // this doesn't get called
    });
});
</script>
<!-- ... this is in <body> -->
<div id="recaptcha_widget" style="display: none">
    <div id="recaptcha_image"></div>
    <div id="recaptcha_links">
        <a href="javascript:Recaptcha.reload()">get another</a> &bull;
        <a class="recaptcha_only_if_image" href="javascript:Recaptcha.switch_type('audio')">switch to audio</a>
        <a class="recaptcha_only_if_audio" href="javascript:Recaptcha.switch_type('image')">switch to image</a> &bull;
        <a href="javascript:Recaptcha.showhelp()">help</a>
    </div>
    <dt>Type the words</dt>
    <dd><input type="text" id="recaptcha_response_field" name="recaptcha_response_field"></dd>
</div>
like image 933
Felix Avatar asked Mar 16 '10 21:03

Felix


1 Answers

Works for me? What is happening? What are you trying to do?

When I substitute and alert for the console.log it alters everytime the page loads or a new reCaptcha gets generated. Exactly like it is supposed to.

The callback is not where you submit it for validation, if that is what you are trying to do then look here: http://recaptcha.net/apidocs/captcha/

like image 157
Dustin Laine Avatar answered Nov 25 '22 10:11

Dustin Laine