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 7429477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:58:34+00:00 2026-05-29T08:58:34+00:00

this works: $.ajax({ type: ‘POST’, url: ‘register.php’, data: {captcha: captcha }, success: function() {

  • 0

this works:

 $.ajax({
            type: 'POST',
            url: 'register.php',
            data: {captcha: captcha
            },

            success: function() {
            $('#loading').hide();
            $('#success').fadeIn();
            } 
            error: function() {
            $('#loading').hide();
            $('#captcha').fadeIn();
            $('#catErrorB').fadeIn();
            } 

});     

sends captcha response to PHP and if entered correctly, you can register. problem is, is that if you incorectly enter your captcha, the JQuery still runs the functions for a successful run although the PHP ran a “die” and did nothing.

In PHP, if the captcha is entered incorrectly is does this

if (!$resp->is_valid) {
           die ("false");
  } 

  else 

  {
  register
  }

How do I request the error that PHP spits out so I can do something like?

    success: function(find error) {
        if(error == "false")
        {
        $('#loading').hide();
    $('#captcha').fadeIn();
    $('#catErrorB').fadeIn();
        }
        else
        {
        $('#loading').hide();
        $('#success').fadeIn();
        }
        } 

EDIT!:
With your help heres what it looks like now and it works fantastic!!

$.ajax({
            type: 'POST',
            url: 'register.php',
            dataType: "json",
            data: {
                challenge: challenge,
                response: response,
                zip: zip
            },

            success: function(result) {  
            if (!result.success) { 
            $('#loading').hide();
            $('#captcha').fadeIn();
            $('#catErrorB').fadeIn();
            } 
            else { 
            $('#loading').hide();
            $('#success').fadeIn();
    } 
} 




});         

and the PHP

if (!$resp->is_valid) {
    $response = array(success => false); 
    echo json_encode($response); 

  } 

  else 
  {

$response = array(success => true); 
echo json_encode($response); 

Ya’ll are the coolest. My first JQuery I’ve ever done, It’s came out so awesome. This site rules!

  • 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-29T08:58:35+00:00Added an answer on May 29, 2026 at 8:58 am

    PHP:

    if (!$resp->is_valid) {
        $response = array(success => false);
        echo json_encode($response);
    }
    else { 
        $response = array(success => true);
        echo json_encode($response);
    }
    

    jQuery:

    success: function(result) { 
        if (!result.success) {
            // Wrong input submitted ..
        }
        else {
            // Correct input submitted ..
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that works well: {livre:empty_name} $.ajax({ url: sent.php, type: post, dataType:
I am using : function ajax(u,s,t) { jQuery.ajax({type: POST, url: u, data: query, success:
This is my code, $.ajax({ type:get, //this doesn't work //url:'http://example.com/json.php', //But this works url:'http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?',
I have following code $.ajax({ type: 'POST', url: 'index.jsp', data: 'id=111', dataType: 'jsonp', success:
At the moment I'm using the post method like this $.ajax({ type: POST, url:
I have a code that calls $.ajax like this : $.ajax({ type: POST, url:
I have the following javascript: $.ajax({ type: "POST", dataType: "json", url: "/Home/Submit", data: {
With the following code: $('#langHref').html(Translating...).css(color,#FF9933); jQuery.ajax({ type: post , url: someUrl , data: {
This works great at retrieving the php data for say 15 passes BUT when
function populateGroups(){ var p =1; var groupNames = new Array(); $.ajax({ type: GET, url:

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.