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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:59:09+00:00 2026-06-11T08:59:09+00:00

For example I have this ajax function but I can call only one json

  • 0

For example I have this ajax function but I can call only one json here what code to add to be able to get more than 1 json:

var blue_name = $("#blue_team #blue_name").val().trim();
            var blue_type = $("#blue_team #blue_type").val().trim();
            var red_name = $("#red_team #red_name").val().trim();
            var red_type = $("#red_team #red_type").val().trim();
            $.ajax({
                url: "battle_review.php",
                type: "post",
                datatype: "json",
                data: { bname: blue_name
                btype: blue_type
                rname: red_name
                rtype: red_type},
                success:function(data){
                    var toAppend = '';
                    if(typeof data === "object"){
                        for(var i=0;i<data.length;i++){
                            //append data here
                        }
                        $("#table1").append(toAppend);// first json
                    }
                }
            });

And here’s my php code and how I put data on my json I want is that i can get the two json’s $blue and $red How to do that?:

    //get blue_team attributes
$blue = array();

$blue_result = $db->dataWarrior($battle,$name);

foreach($blue_result as $warrior){
    $blue[] = $names;
}



//get red_team attributes
$red = array();

$red_result = $db->dataWarrior($battle,$name);

foreach($red_result as $warrior){
    $red[] = $names;
}

echo json_encode(array('red'=>$red,'blue'=>$blue));
  • 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-11T08:59:10+00:00Added an answer on June 11, 2026 at 8:59 am

    You want to retrieve more than one array on one single AJAX call? Just make… an array of array!

    Instead of two json_encode call, just put:

    echo json_encode(array('red' => $red, 'blue' => $blue));
    

    Then, in your Javascript code, you can access them via data.blue and data.red.

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

Sidebar

Related Questions

I have this example code, but i believe when i call the ajax function
I have an ajax call to one php script via jquery but it takes
For example we have this line chart at Google Code API there is a
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
In my JS I have the following ajax call, that bind the resulting json
I have this jQuery ajax call: $.ajax({ url : 'my_action', dataType: 'script', beforeSend :
I have a following (simplified) code: var myModule = { submitDummyForm: function(){ console.log(this); //
For example i have this xml. I need to get value of parameter val
OK. For example I have this line in my txt file: 1|1,12;7,19;6,4;8,19;2,2 As you
How would I split a node/element at a position (selection). Example I have this

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.