8

我看不出我哪里错了。我已经尝试了我能想到的一切,reCAPTCHA 只是无法使用 Ajax API。这是我的代码的样子:

<!-- 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>
4

2 回答 2

6

对我有用吗?怎么了?你想做什么?

当我替换并提醒 console.log 时,它会在每次页面加载或生成新的 reCaptcha 时发生变化。就像它应该的那样。

回调不是你提交验证的地方,如果这是你想要做的,那么看看这里:http ://recaptcha.net/apidocs/captcha/

于 2010-03-16T21:17:54.010 回答
2

很抱歉再次回答我的问题。发现了问题,显然您不能在本地存储的文件(通过访问file:///)中使用 reCAPTCHA,它们必须在http://站点上。一旦我把它放在本地主机上,它就起作用了。

+1 durilai 让我知道它适用于他/她,这样我就能够从不同的角度看待问题。

于 2010-03-16T21:29:26.603 回答