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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:34:57+00:00 2026-06-10T02:34:57+00:00

I have a situation where i have a drop down in php file ‘A’.and

  • 0

I have a situation where i have a drop down in php file ‘A’.and when i select a value from that drop down an ajax call is made and a different php file B is triggered.
In that file,i do db fetch,and form two json objects.these two json objects are required for me to draw 2 different data tables and 2 different charts.

  1. when i echo one json object in ‘B’ i get that as a response to ajax call in ‘A’

  2. I cant even get a response if i echo two json objects in B.

  3. for a single json object response,i can draw datatable and can manipulate json object with javascript and hopefully draw chart

Please advise how to handle this situation
Code from file B

        $json = json_encode($tot_categ);
        $json_percent = json_encode($tot_que_percent);
            $cols_percent = array(
                array( 'id' => 't', 'label' => 'Title', 'type' => 'string'),
                array( 'id' => 'n', 'label' => 'Neutral(+) ', 'type' => 'string'),
                array('id' => 'a', 'label' => 'Agree', 'type' => 'string'),
                array('id' => 'ne', 'label' => 'Neutral(-)', 'type' => 'string'),
                array('id' => 'd', 'label' => 'Disagree', 'type' => 'string'),

        );

        $jcols_percent = json_encode($cols_percent);
        //JSON format accepted by Google tables
        $r_percent= "{cols:".$jcols_percent.','."rows:".$json_percent."}";
        //echo (JSON.stringify($r_percent));
        // echo $r_percent;

        $cols = array(
                array( 'id' => 't', 'label' => 'Title', 'type' => 'string'),
                array( 'id' => 'l', 'label' => 'Avg ', 'type' => 'string'),
                array('id' => 'lb', 'label' => 'High', 'type' => 'string'),
                array('id' => 'lo', 'label' => 'Low', 'type' => 'string')
        );

        $jcols = json_encode($cols);
        //JSON format accepted by Google tables
        $r = "{cols:".$jcols.','."rows:".$json."}";
        //echo(json_decode($r));
        echo $r;

$r and $r_percent are my objects

$r_percent when echoed gives

{cols:[{"id":"t","label":"Title","type":"string"},{"id":"n","label":"Neutral(+) ","type":"string"},{"id":"a","label":"Agree","type":"string"},{"id":"ne","label":"Neutral(-)","type":"string"},{"id":"d","label":"Disagree","type":"string"}],rows:[{"c":[{"v":"165q"},{"v":0},{"v":0},{"v":0},{"v":100}]},{"c":[{"v":"160q"},{"v":0},{"v":0},{"v":0},{"v":6}]},{"c":[{"v":"161q"},{"v":0},{"v":0},{"v":0},{"v":10}]},{"c":[{"v":"162q"},{"v":7},{"v":0},{"v":7},{"v":0}]},{"c":[{"v":"163q"},{"v":0},{"v":25},{"v":0},{"v":0}]},{"c":[{"v":"164q"},{"v":0},{"v":100},{"v":0},{"v":0}]}]}

$r when echoed gives

{cols:[{"id":"t","label":"Title","type":"string"},{"id":"l","label":"Avg ","type":"string"},{"id":"lb","label":"High","type":"string"},{"id":"lo","label":"Low","type":"string"}],rows:[{"c":[{"v":"165q"},{"v":1.3333333333333},{"v":"2"},{"v":"1"}]},{"c":[{"v":"160q"},{"v":6},{"v":"10"},{"v":"1"}]},{"c":[{"v":"161q"},{"v":6.6666666666667},{"v":"9"},{"v":"2"}]},{"c":[{"v":"162q"},{"v":7},{"v":"9"},{"v":"3"}]},{"c":[{"v":"163q"},{"v":8},{"v":"9"},{"v":"6"}]},{"c":[{"v":"164q"},{"v":5},{"v":"5"},{"v":"5"}]}]}

when combined

$result = array('objA' => $r_percent, 'objB' => $r );
        echo json_encode($result);

updated echoing

{"objA":"{cols:[{\"id\":\"t\",\"label\":\"Title\",\"type\":\"string\"},{\"id\":\"n\",\"label\":\"Neutral(+) \",\"type\":\"string\"},{\"id\":\"a\",\"label\":\"Agree\",\"type\":\"string\"},{\"id\":\"ne\",\"label\":\"Neutral(-)\",\"type\":\"string\"},{\"id\":\"d\",\"label\":\"Disagree\",\"type\":\"string\"}],rows:[{\"c\":[{\"v\":\"165q\"},{\"v\":0},{\"v\":0},{\"v\":0},{\"v\":100}]},{\"c\":[{\"v\":\"160q\"},{\"v\":0},{\"v\":0},{\"v\":0},{\"v\":6}]},{\"c\":[{\"v\":\"161q\"},{\"v\":0},{\"v\":0},{\"v\":0},{\"v\":10}]},{\"c\":[{\"v\":\"162q\"},{\"v\":7},{\"v\":0},{\"v\":7},{\"v\":0}]},{\"c\":[{\"v\":\"163q\"},{\"v\":0},{\"v\":25},{\"v\":0},{\"v\":0}]},{\"c\":[{\"v\":\"164q\"},{\"v\":0},{\"v\":100},{\"v\":0},{\"v\":0}]}]}","objB":"{cols:[{\"id\":\"t\",\"label\":\"Title\",\"type\":\"string\"},{\"id\":\"l\",\"label\":\"Avg \",\"type\":\"string\"},{\"id\":\"lb\",\"label\":\"High\",\"type\":\"string\"},{\"id\":\"lo\",\"label\":\"Low\",\"type\":\"string\"}],rows:[{\"c\":[{\"v\":\"165q\"},{\"v\":1.3333333333333},{\"v\":\"2\"},{\"v\":\"1\"}]},{\"c\":[{\"v\":\"160q\"},{\"v\":6},{\"v\":\"10\"},{\"v\":\"1\"}]},{\"c\":[{\"v\":\"161q\"},{\"v\":6.6666666666667},{\"v\":\"9\"},{\"v\":\"2\"}]},{\"c\":[{\"v\":\"162q\"},{\"v\":7},{\"v\":\"9\"},{\"v\":\"3\"}]},{\"c\":[{\"v\":\"163q\"},{\"v\":8},{\"v\":\"9\"},{\"v\":\"6\"}]},{\"c\":[{\"v\":\"164q\"},{\"v\":5},{\"v\":\"5\"},{\"v\":\"5\"}]}]}"}
  • 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-10T02:34:58+00:00Added an answer on June 10, 2026 at 2:34 am

    Combine both responses in a single object, return that object and use both parts separately again:

    PHP side:

    $result = array( 'objA' => $objA, 'objB' => $objB );
    echo json_encode( $result );
    

    Client side:

    // your success callback handler
    function handler( data ) {
      // execute code for object A
      doStuff( data.objA );
      // execute code for object B
      doOtherStuff( data.objB );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP - PRE-select drop down option I have a situation in my
I have a situation where I have multiple drop down lists that are hidden
Here's the situation I have a webpage which has one drop down called prefer.
I have this situation: <select name=year > <?php $today = date(Y); for ($i=2005; $i<=$today;
The situation I have is a drop down list and an image on a
I need a javascript solution for the following situation: I have two select drop
Here's the situation: I have a menu that needs to be created dynamically from
I have situation, where running a query that filters by an indexed column in
I have situation in which I read a record from a database. And if
We have situation where say we have four engineers that are working on software

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.