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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:22:13+00:00 2026-05-27T17:22:13+00:00

I have an AJAX request that fetches some info from a SQL database in

  • 0

I have an AJAX request that fetches some info from a SQL database in PHP.

The problem is, I need to send it back to AJAX in variables. Not to just echo it all out on screen.

Is this possible? If so, how would I go about doing something like this?

Thanks.

  • 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-27T17:22:13+00:00Added an answer on May 27, 2026 at 5:22 pm

    Yes, you could json_encode the variable you want to send back to client.

    echo json_encode( array('variable' => 'your value' ) ); 
    

    The client will receive the data through a callback when the request is completed. Without more clarification on specifics that’s all i can offer, with some more details i can provide code samples depending on whether you’re using a JavaScript library such as jQuery or doing a raw XHR request.

    Edit: so in jquery to retrieve the variable above you would do the following.

    $.getJSON('yourfile.php', function(data){
          console.log( data.variable ); 
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ajax request that gets back some html <div id=test> </div> in
I have an jquery ajax request that calls a PHP script that will send
I have an $.ajax() request that queries currency exchange rate information from another web
I have an AJAX request (using JQuery) that calls a PHP script which does
I have a php script that fetches data from a DB, the result set
I'm not sure where the problem is... I have an ajax request that checks
I have an ajax request that requests a php script that connects to my
I have jQuery Ajax request that sends data to a PHP page that then
I'm developing a website using PHP+Ajax. I have to fire a ajax request that
Is it possible that using jQuery, I cancel/abort an Ajax request that I have

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.