开发者

jQuery: loading reCaptcha into a div via ajax

开发者 https://www.devze.com 2023-01-03 10:23 出处:网络
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\"

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 ."]]>开发者_StackOverflow中文版</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?

0

精彩评论

暂无评论...
验证码 换一张
取 消