jQuery:通过 ajax 将 reCaptcha 加载到 div 中
我想创建一个包含 id 为“captcha”的 div 的表单。当用户输入错误的密码时,“login.php”中会生成以下代码
$myCaptcha=recaptcha_get_html($publickey, $error);
$xml="<captcha><![CDATA[".$myCaptcha ."]]></captcha>";
echo $xml;
recaptcha_get_html($publickey, $error);
生成以下代码:
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=xxxx"></script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=xxxx" 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>
我想使用 $.post() 获取此代码并且将其插入 div“验证码”中。做这样的事情:
$.post("login.php", {requestCaptcha:"yes"}, function(returned){
$("#captcha").html($("captcha",returned).text());
},"xml");
在 IE 中,它什么也不做。在 Chrome 中,它会清除整个页面,只有名为 reCaptcha 的脚本像魅力一样工作。
有什么想法吗?
I want to create a form that has a div with id "captcha". When the user enters a wrong password, following code is generated in "login.php"
$myCaptcha=recaptcha_get_html($publickey, $error);
$xml="<captcha><![CDATA[".$myCaptcha ."]]></captcha>";
echo $xml;
recaptcha_get_html($publickey, $error);
generates this:
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=xxxx"></script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=xxxx" 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>
I want to get this code with $.post() and insert it into div "captcha". Doing something like this:
$.post("login.php", {requestCaptcha:"yes"}, function(returned){
$("#captcha").html($("captcha",returned).text());
},"xml");
In IE, it does nothing. In Chrome, it clears up whole page and there is only the called reCaptcha script working like a charm.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论