jQuery: loading reCaptcha into a div via ajax

Posted by abdullah kahraman on Stack Overflow See other posts from Stack Overflow or by abdullah kahraman
Published on 2010-06-10T00:28:08Z Indexed on 2010/06/10 0:32 UTC
Read the original article Hit count: 482

Filed under:
|
|
|
|

Hello, 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($(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?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX