Welcome Guest, Not a member yet? Register   Sign In
reCAPTCHA not showing after an ajax call

I'm trying to insert a reCAPTCHA code into my login form and everything went pretty well.

But since the form is sent trough an ajax $.(post) command, if the form_validation->run() fails the page is reloaded.

if the form is reloaded, it seems that reCAPTCHA can't be reloaded into the form and I can't figure out why.

here is the view code:

    $(function() {
            $( "#submit" ).button();
    function showRecaptcha(element) {
           Recaptcha.create("6LcjCMYSAAAAAB7KIMKe3m4JyWse3xS8p74Ri50O", element, {
             theme: "red",
             callback: Recaptcha.focus_response_field});
            $.post("<?=base_url();?>aziende/login", $("#loginform").serialize(),function(data){
<?php if(!$submitted) { ?>
<div id="loading" align="center"><img src="&lt;?=base_url();?&gt;images/loading.gif" /></div>
<div id="formcontainer">
    &lt;?php } ?&gt;
    <div align="center" id="formError">&lt;?php echo validation_errors(); ?&gt;</div><br />
&lt;form method="post" action="" id="loginform"&gt;
<table border="0" width="100%">
        <tr><td align="right" width="50%">
    <label for="email">Email:</label></td>
        <td align="left">&lt;input type="text" name="email" placeholder="Il tuo indirizzo email" value="&lt;?=$email;?&gt;" /&gt;&lt;/td>
        <tr><td align="right">
    <label for="password">Password:</label></td>
        <td align="left">&lt;input type="password" name="password" value="&lt;?=$password;?&gt;" /&gt;&lt;br />
    <tr><td colspan="2" align="center"><div id="recaptcha_div"></div></td></tr>
    <tr><td colspan="2" align="center">&lt;input type="hidden" name="go" value="1" /&gt;&lt;br />
      &lt;input type="submit" value="Registrati!" id="submit" /&gt;&lt;/td>
&lt;?php if(!$submitted) { ?&gt;</div>&lt;?php } ?&gt;

I tried loading reCAPTCHA without the javascript command (trough iframe) but the problem seems to persist.

this is the view that is reloaded with ajax on form error.

when I say that reCAPTCHA is not reloaded I mean that the whole reCAPTCHA box is not showing up...

ty for help Smile

- sometimes it works without any code change...
- if I submit the right word the login is successfull, so there is no controller error on form_validation
- the first "removed" items on my code are the script for google reCAPTCHA api

Messages In This Thread
reCAPTCHA not showing after an ajax call - by El Forum - 10-13-2011, 12:47 PM

Theme © iAndrew 2016 - Forum software by © MyBB