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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:09:08+00:00 2026-06-09T21:09:08+00:00

I want the data returned from an ajax post to be put into a

  • 0

I want the data returned from an ajax post to be put into a javascript variable where I can then run an if statement checking whether that variable is equal to true. However, Firebug is telling me the variable verify is not defined. How do I write the function within the ajax post to set the data to verify correctly? Code is below.

$.post('ajax_file.php', 
{
user_id: user_id,    
band_term: band_term
}, function (data) {
var verify = data;              

if (verify == 'true') 

   {

   $('#request_form').hide();                  

   $('#where_to_go').hide();                            

   $('#change_form').show();                                    

}});

The ajax file returns true on success and false on failure.

if (mysql_query($sql) == true)

{ echo 'true';} else {echo 'false';}

Firebug shows me that the ajax file is returning with the string true, so I know the ajax file is working.

  • 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-06-09T21:09:10+00:00Added an answer on June 9, 2026 at 9:09 pm

    The issue is on a few places.
    First, how you output data on you .php file. You should be returning JSON and accepting JSON on you ajax request. Look at this example:

    <?php
        $variable = array("stat" => true, "data" => array(10, 10));
        print_r(JSON_Encode($variable));
    ?>
    

    That will output this:

    {"stat":true,"data":[10,10]}
    

    Then on yout JS you’d do:

    $.post('ajax_file.php', {
       user_id: user_id,    
       band_term: band_term
    }, function (data) {
       //Data is the whole object that was on the response. Since it's a JSON string, you need to parse it back to an object.
    
       data = JSON.parse(data);
    
       if (data.stat === true){
          $('#request_form').hide();                  
          $('#where_to_go').hide();                            
          $('#change_form').show();                                    
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a post where I am returned with some data from
I want to show data that returned from controller, in onComplete function: function onComplete()
I want to call a web page from Flash and use the data returned
I want pull the data from only a specific column, but what Is returned
Basically I want get data I already have accessed from javascript and passing it
I am trying to configure returned data from $.ajax() by jQuery... My example is
Being relatively new to javascript, AJAX and jQuery, I want to post 3 values
I'm using the jQuery DataTables plugin to display data being returned from an AJAX
I want to be able to Ajax-ly retrieve JSON data from some kind of
I have a problem returning data back to the function I want it returned

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.