Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4125922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:55:58+00:00 2026-05-20T23:55:58+00:00

I have a form that validates and posts with Ajax, or more specifically, with

  • 0

I have a form that validates and posts with Ajax, or more specifically, with $.post().

At one point, there is a reCaptcha. This form worked fine when I did not use $.post() but posted the old-fashioned way (with a page refresh), just for reference.

Converting the form requires that I changed all $_POST‘s to $_REQUEST‘s. However, this doesn’t remedy the reCaptcha problem, so I’ve left that intact. Here is the reCaptcha PHP code inside registerPost.php:

  require_once('recaptchalib.php');
  $privatekey = "dropbeatsnotbombs";
  $resp = recaptcha_check_answer ($privatekey,
                            $_SERVER["REMOTE_ADDR"],
                            $_POST["recaptcha_challenge_field"],
                            $_POST["recaptcha_response_field"]);

 if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
echo "Error";
}
else {
   //post form
}

Here’s the jQuery handling the form posting:

$.post('php/registerPost.php', $('#registerPost').serialize(), function(data){
                if(data == "Error")
                {
                    $('#caErr').show();
                }
                else
                {
                    window.location.replace("//main page");
                }
            });

Note: the reCaptcha seems to return as false, since the form will not submit when everything is filled in correctly.

What I want to do is show an error if the reCaptcha was entered wrong, and post if it was entered right, all asynchronously.

Any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:55:59+00:00Added an answer on May 20, 2026 at 11:55 pm

    Hmm. I need to go read the API documentation for $.post(), but my first guess is that since the form is not really submitted, the $_POST array is not being populated, so when you use values like $_POST["recaptcha_challenge_field"], it’s just an empty field. Again, I need to go verify that, but that is my hunch.

    EDIT:

    Looks like I was wrong. I compared what you have to both the API and an older script I had, and what you are doing should be fine. The only difference I see is that you are passing this as data:

    $('#registerPost').serialize()
    

    whereas my script was passing this:

    $('#form').serializeArray()
    

    It could be as simple as that…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.