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

  • SEARCH
  • Home
  • 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 6162833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:43:17+00:00 2026-05-23T21:43:17+00:00

I have a variable called captcha from input in my form. In my javascript

  • 0

I have a variable called captcha from input in my form.

In my javascript file I have this:

  var captcha = $("input#captcha").val();
                    $.ajax({
                            type: "GET",
                            url: "includes/process.php",
                            data: captcha,
                            success: function() {

                              alert('Captcha is OK');

                            }
                          });

In my process.php file I have this:

<?php

// Begin the session
session_start();

// To avoid case conflicts, make the input uppercase and check against the session value
// If it's correct, echo '1' as a string
if(strtoupper($_GET['captcha']) == $_SESSION['captcha_id'])
    echo 'true';
// Else echo '0' as a string
else
    echo 'false';

?>

And my problem is that it always pass as OK, no matter what I type into input. How can I e.g. sand back to my javascript containing file the value of captcha_id so I can check it e.g. using alert in javascript?

I think that my php file is wrong, because no matter what I type into my captcha (I have checked it using alert(captcha); after var captcha = $(“input#captcha”).val(); and it alert the correct value.

So, I assume that the success: … part is wrong

or

the php comparison part in process.php . What does it have to return for success part of ajx to be executed?

Thanks for any advice.

SOLVED ! at least for me 😉

This is working for me :

$.ajax({
                                type: "GET",
                                url: "includes/process.php",
                                data: "captcha=" + captcha,
                                success:function(data){
                                    if(data=='true')
                                    alert("OK");

                                else
                                alert("not ok");

                                }
                          });

process.php remains untouched.

Thanks you all, you have helped me a lot.

  • 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-23T21:43:19+00:00Added an answer on May 23, 2026 at 9:43 pm

    you are not capturing the response from the server in your success call back

    success:function(data){
    if(data=='true')
    alert("OK");
    
    else
    alert("not ok");
    
    }
    

    also you may need to send the data in your ajax call as

    data:{captcha:captcha},
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable called account_type passed from a rails form and need to
On my website I have a variable called $user_data that contains input from a
I have a PHP-variable called $go_Adress which contains the adress I need to get
I have a hidden input variable called str. I am assigning abc value to
I have a paragraph of text in a javascript variable called 'input_content' and that
I have four checkboxes in my form. I have string variable called CheckedString. If
I have a variable called $tags , which just references from a database field.
I have a variable called @status which I set before this select statement: Select
I have a variable called $result which should store all the results from my
I have a variable called root. The value for this variable is 0 $root

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.