views:

286

answers:

1

Hi, I've been trying to make this code work for the last 3 hours. I've tried about everytinh, but I'm still unable to get it to work.

I only managed to send 1 data.

When I use this code, I only manage to retrieve recaptcha_response_field. If I remove recaptcha_response_field, I retrieve recaptcha_challenge_field. However, I am unable to retrieve the two at the same time.

challengeField = $("#recaptcha_challenge_field").val();
responseField = $("#recaptcha_response_field").val();

var html = $.ajax(
    {
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "recaptcha_response_field=" + responseField + "&recaptcha_challenge_field=" + challengeField,
        url: "../ajax.recaptcha.php"
    }).responseText;

if(html == "success")
{
    $("#captchaStatus").html("Success. Submitting form.");
    return true;
}
else
{
    $("#captchaStatus").html("Your captcha is incorrect. Please try again");
    Recaptcha.reload();
    return false;
}
A: 

Try

data: {
    recaptcha_response_field: responseField,
    recaptcha_challenge_field: challengeField
}

??

What do you mean that $_POST["recaptcha_response_field"] and $_POST["recaptcha_challenge_field"] are not both set "inside" ajax.recaptcha.php.

That's impossible Firebug's Net-Tab shows that the request just works fine.

Did you check your server logs (enable post data logging temporarily )

jitter
Once again, only one works
Guillaume P
Check expanded answer
jitter
Yeah that's exactly what I mean. I don't know why however...I'm using joomla if that can helps.There's nothing relevant in the servers logs.Thank you
Guillaume P
just btw. can't you just use some of the existing recaptcha / joomla plugins? http://extensions.joomla.org/extensions/search/reCaptcha or just google for it
jitter