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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:28:08+00:00 2026-05-26T23:28:08+00:00

How can I retrieve a PHP variable from jQuery? If I am using a

  • 0

How can I retrieve a PHP variable from jQuery? If I am using a jQuery POST function such as this:

$.post("login.php", {username:username, password:password}, function(data){
    $('section').html(data);
});

Instead of showing ‘data’ is it possible to show a certain PHP variable from the PHP file to output?

  • 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-26T23:28:09+00:00Added an answer on May 26, 2026 at 11:28 pm

    login.php:

    <?php
    
    echo 'hello';
    

    would then return hello as the contents of your data variable in the ajax call. JS cannot directly access PHP variables, unless PHP choses to output those variables’ contents via the response to the ajax call. If you need to pass back multiple variables/values, then use a JSON container:

    <?php
    
    echo json_encode(array('hello' => 'there', 'how' => 'are', 'you' => '?'))
    

    would give you 3 pieces of data (‘hello’, ‘how’, ‘you’) which contain ‘there’, ‘are’, and ‘?’, respectively. You’d access them as data['hello'], data['how'], data['you'].

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

Sidebar

Related Questions

How can I insert an image in MySQL and then retrieve it using PHP?
I developp a Java application using Windows Desktop Search from which I can retrieve
I want to retrieve the JSON from http://www.bartdekimpe.be/anoire/index.php/admin/getGamesUserJson/34 but I can't seem to get
I'm trying to retrieve data from a POST method, code as follows: -(void)postXMLFeed:(NSString *)XMLStrPost
How can I pass multiple variables between PHP files using jquery with json? Ex:
I'm trying to feed data from SQL database to FLEX, using php script in
How can I create a simple PHP file, which will retrieve the HTML and
I know I can retrieve some settings.xml parameters using properties, like, for example ${settings.localRepository}
In asp.net, you can retrieve MULTIPLE datatables from a single call to the database.
How can I retrieve the page title of a webpage (title html tag) using

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.