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

The Archive Base Latest Questions

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

I have a page where a user can view more info, an ID is

  • 0

I have a page where a user can “view more info”, an ID is sent to a php page which then queries the database. It then returns some data, with some of the data I want to put this into a textarea, the other into a standard div.

How can I send multiple responses back, and how do I know what the data is? e.g. send name and address, how do I know what the php page is sending back so that I can interpret the data on client side?

Is there a better way than using

httpxml.responseText.indexOf("something")

As the two responses may contain similar data? What I hope to do is send two variables from the PHP page and then “see” these variables on client side?

Hope I haven’t made this too confusing, thanks.

Javascript only please.

  • 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-18T09:17:23+00:00Added an answer on May 18, 2026 at 9:17 am

    Return JSON containing all your values from the PHP. Then after getting the response your javascript can do whatever you’d like to do with the values.

    http://www.php.net/manual/en/function.json-encode.php

    –PHP–

    $responseArr = array('a'=>1, 'b'=>2);
    echo json_encode($responseArr);
    

    If I remember correctly (i do this with jQuery now), just performing eval() on your response text will form the object for you.

    –javascript– (just vanilla js right? you didnt mention jQuery or anything)
    this is probably inside your onreadystatechange block

    var r = xhr.responseText;   //assuming you name the XMLHttpRequest object 'xhr'
    var rlist = eval('('+r+')');
    document.getElementByID("foo").innerHTML = rlist['a']; //or whatever you want to do with these
    document.getElementByID("bar").innerHTML = rlist['b'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page where a user can upload a file along with some
I have this PHP page where the user can select and un-select items. The
I have a page which contains a dynamically generated grid, where a user can
I have a page where a user can import data to the site. either
I have a page where the user can dynamically add file upload boxes. Adding
I have a page where the user can edit various content using buttons and
I have a form on a page that a user can use to create
I have a section on a page where a user can change their username.
I have a list of items on my web page that the user can
I have a JSP page, so the user can insert the time when he/she

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.