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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:22:57+00:00 2026-06-08T21:22:57+00:00

I am passing a multidimensional array back to a .php file using json, jquery,

  • 0

I am passing a multidimensional array back to a .php file using json, jquery, and ajax. My goal is essentially to fill a drop down box (id=project) with multiple entries. Here’s some code snippets:

$("#turninId").change(function() {

        var user_id = $("#turninId").val();

        $.ajax ( {
          url:"send_input.php",
          type: "POST",
          dataType: "json",
          data:{id_selection: user_id},
          success:function(response) {

            for (var i=0; i<response.proj.length; i++) {
              $("#exp").html(response.proj[i]);
              $("#project").html(response.proj[i]); } });

     });

In send_input.php (backend), I query a db, and send the information to an array. Then I use json_encode.

$query="SELECT project FROM main";
$results = $db->query($query);
while ($row_id = $results->fetchArray()) {
       $proj_option[] = "<option value=\"".$row_id['project']."\">".$row_id['project']."</option>\n";
           $pselected=$row_id['project'];
}
$output = array( "proj" => "$proj_option");
echo json_encode($output);

My problem is that this is RETURNING THE STRING “Array”.

For example, if I do: response.proj[0], I get “A” returned.

What gives? I’ve seen a few people with questions about this error, but no definite solution. Any help?

  • 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-08T21:22:58+00:00Added an answer on June 8, 2026 at 9:22 pm

    This is because you are casting $proj_option to a string by enclosing it in quotes. Just remove the quotes and you will get the array.

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

Sidebar

Related Questions

I have gathered data with jQuery, putten it into a multidimensional array, used JSON.stringify
i have a multidimensional array. the array is returned by parsing xml using curl.
Ok, In my Codeigniter project I am passing a multidimensional array to my view.
Passing Parameter to the Java file using Html form I couldn't run in my
I'm currently passing a multidimensional char array to my MySQL function. cmd contains the
I want to know the way of passing multidimensional in URL with php. I
Here (given below) is some very simple php parsing multidimensional array stuff I am
So,is Passing a multidimensional array from C++ to Lua actually possible? Or should I
In my php code, I have <?php $test = json_encode($array);//$array is a valid multidimensional
passing post data using cURL requires that the name of the input. However, I

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.