为什么不是';是否使用XMLHttpRequest从PHP中重新显示TCHA?

为什么不是';是否使用XMLHttpRequest从PHP中重新显示TCHA?,php,javascript,html,ajax,captcha,Php,Javascript,Html,Ajax,Captcha,::解释:: 在HTML文件中,我试图加载带有验证码检查的注册帧。表单本身就会显示出来。验证码不存在。所以我知道javascript(发布在下面)得到了我想要的东西。但是我的验证码出现了问题 最后一点,我将id为“splashTarget”的div作为目标,我使用CSS来安排我想要的一切。我不打算发布它,因为它可能不相关,但如果你认为我确实需要发布它以获得帮助,请让我知道 ::代码:: 似乎不起作用的表单: <div class="splash"> </div> <

::解释::

在HTML文件中,我试图加载带有验证码检查的注册帧。表单本身就会显示出来。验证码不存在。所以我知道javascript(发布在下面)得到了我想要的东西。但是我的验证码出现了问题

最后一点,我将id为“splashTarget”的div作为目标,我使用CSS来安排我想要的一切。我不打算发布它,因为它可能不相关,但如果你认为我确实需要发布它以获得帮助,请让我知道

::代码::

似乎不起作用的表单:

<div class="splash"> </div>
<div style="text-align:left" id="registrationSplash" class="splashContent">
    <div style="text-align:right">
        <a style="color:darkred" href="javascript:closeSplash()">[ CANCEL ]</a>
    </div>
    <h1>REGISTER</h1>
    <form action="" method="post" id="registerForm">
                <?PHP
                require_once('recaptchalib.php');
                $publickey = "[censored]";                  
                echo recaptcha_get_html($publickey);
                echo '<!--'.recaptcha_get_html($publickey).'-->';
                ?>
        <table>
            <tr>
                <td>First Name:</td>
                <td><input type="text" name="firstname" maxlength="60"></td>
                <td>Username:</td>
                <td><input type="text" name="username" maxlength="30"></td>
            </tr>

            <tr>
                <td>Last Name:</td>
                <td><input type="text" name="lastname" maxlength="60"></td>
                <td>Password:</td>
                <td><input type="password" name="pass" maxlength="30"></td>
            </tr>

            <tr>
                <td>E-mail Address:</td>
                <td><input type="text" name="firstname" maxlength="60"></td>
                <td>Confirm Password:</td>
                <td><input type="password" name="pass2" maxlength="30"></td>
            </tr>

            <tr>
                <th colspan=4 style="text-align:right">

                <button onclick="submitFormRegisterSplash()" type="button" name="submit" value="Login">Register!</button>
                </th>
            </tr> 
        </table>
    </form>

    <div id="status" />
</div>
调用创建后网页上的结果

<div id="splashTarget">

<div class="splash"> </div>
<div style="text-align:left" id="registrationSplash" class="splashContent">
    <div style="text-align:right">
        <a style="color:darkred" href="javascript:closeSplash()">[ CANCEL ]</a>
    </div>
    <h1>REGISTER</h1>
    <form action="" method="post" id="registerForm">
                <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>

    <noscript>
        &lt;iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;
        &lt;textarea name="recaptcha_challenge_field" rows="3" cols="40"&gt;&lt;/textarea&gt;
        &lt;input type="hidden" name="recaptcha_response_field" value="manual_challenge"/&gt;
    </noscript><!--<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>

    <noscript>
        <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"></iframe><br/>
        <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
        <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
    </noscript>-->      <table>
            <tbody><tr>
                <td>First Name:</td>
                <td><input type="text" name="firstname" maxlength="60"></td>
                <td>Username:</td>
                <td><input type="text" name="username" maxlength="30"></td>
            </tr>

            <tr>
                <td>Last Name:</td>
                <td><input type="text" name="lastname" maxlength="60"></td>
                <td>Password:</td>
                <td><input type="password" name="pass" maxlength="30"></td>
            </tr>

            <tr>
                <td>E-mail Address:</td>
                <td><input type="text" name="firstname" maxlength="60"></td>
                <td>Confirm Password:</td>
                <td><input type="password" name="pass2" maxlength="30"></td>
            </tr>

            <tr>
                <th colspan="4" style="text-align:right">

                <button onclick="submitFormRegisterSplash()" type="button" name="submit" value="Login">Register!</button>
                </th>
            </tr> 
        </tbody></table>
    </form>

    <div id="status">
</div>

</div></div>

登记
iframe src=”http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV“height=“300”width=“500”frameborder=“0”/iframebr/
textarea name=“recaptcha\u challenge\u field”rows=“3”cols=“40”/textarea
输入type=“hidden”name=“recaptcha\u response\u field”value=“manual\u challenge”/
名字:
用户名:
姓氏:
密码:
电子邮件地址:
确认密码:
登记
该网站是gumonshoe dot net slash Registration 您需要选择尝试注册以查看弹出窗口。我禁用了创建启动屏幕的CSS,认为这可能是z索引的问题。情况似乎并非如此


感谢您提供的提示。

明显的问题:插入的recaptcha代码被注释为
。注释掉的html/js不会被呈现/执行。改变

echo '<!--'.recaptcha_get_html($publickey).'-->';
表单HTML确实有效(请参阅)。该错误是由以下功能引起的:

使用
.innerHTML=…
注入的标记<代码>未被解析(这些标记中的函数和变量未定义,也未调用)。您必须在页面中包含验证码,而不是使用AJAX添加验证码

编辑 添加此HTML代码(在
块内):


根据我的建议覆盖您的函数(用您的公钥替换
):

函数onRegisterClicked(){ create(“,”splashTarget“{ 主题:“红色”, 回调:Recaptcha.focus\u response\u字段 }); }
我重复了两次,因为我想在评论中加入一个确切的内容:echo recaptcha\u get\u html($publickey);回显“”;::所以,对不起,这不是答案。但愿是这样(是否还有其他函数可以解析给出的内容?可能通过调用eval或类似的方法?请参阅我的更新答案。如果您的问题已得到回答,请使用“接受答案”,以便其他访问者(例如,来自谷歌)知道此答案是正确的。为了实现我的愿望,我做了以下操作:(1)在我的表单中添加了一个。)按照Rob W的建议执行上述操作,将splashTarget更改为captchaTarget,但在我的Ajax请求中。(3)从其他位置删除了脚本代码。--非常感谢您将我带到正确的位置。
<div id="splashTarget">

<div class="splash"> </div>
<div style="text-align:left" id="registrationSplash" class="splashContent">
    <div style="text-align:right">
        <a style="color:darkred" href="javascript:closeSplash()">[ CANCEL ]</a>
    </div>
    <h1>REGISTER</h1>
    <form action="" method="post" id="registerForm">
                <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>

    <noscript>
        &lt;iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;
        &lt;textarea name="recaptcha_challenge_field" rows="3" cols="40"&gt;&lt;/textarea&gt;
        &lt;input type="hidden" name="recaptcha_response_field" value="manual_challenge"/&gt;
    </noscript><!--<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>

    <noscript>
        <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"></iframe><br/>
        <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
        <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
    </noscript>-->      <table>
            <tbody><tr>
                <td>First Name:</td>
                <td><input type="text" name="firstname" maxlength="60"></td>
                <td>Username:</td>
                <td><input type="text" name="username" maxlength="30"></td>
            </tr>

            <tr>
                <td>Last Name:</td>
                <td><input type="text" name="lastname" maxlength="60"></td>
                <td>Password:</td>
                <td><input type="password" name="pass" maxlength="30"></td>
            </tr>

            <tr>
                <td>E-mail Address:</td>
                <td><input type="text" name="firstname" maxlength="60"></td>
                <td>Confirm Password:</td>
                <td><input type="password" name="pass2" maxlength="30"></td>
            </tr>

            <tr>
                <th colspan="4" style="text-align:right">

                <button onclick="submitFormRegisterSplash()" type="button" name="submit" value="Login">Register!</button>
                </th>
            </tr> 
        </tbody></table>
    </form>

    <div id="status">
</div>

</div></div>
echo '<!--'.recaptcha_get_html($publickey).'-->';
echo recaptcha_get_html($publickey);
<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
function onRegisterClicked() {
    Recaptcha.create("<PUBLIC KEY HERE>", "splashTarget", {
        theme: "red",
        callback: Recaptcha.focus_response_field
    });
}