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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:20:20+00:00 2026-05-16T12:20:20+00:00

I am trying to pass a nested array to an asp.net mvc controller like

  • 0

I am trying to pass a nested array to an asp.net mvc controller like this:

var subgroups = [];
subgroups [0] = [["A", "Y"],
                 ["B", "Y"],
                 ["C", "Y"]];
subgroups [1] = [["D", "Z"],
                 ["E", "Z"],
                 ["F", "Z"]];

$.ajax({ url: "<%= Url.Content("~/Controller/Action") %>", data: { subgroups: subgroups },
         dataType: "json", context: document.body, success: function(data) { ... } );

The resulting controller:

public ContentResult Action(List<string[][]> subgroups) {
    ...
}

The problem is the resulting subgroups variable in the controller looks like this:

subgroups[0][0] == null;
subgroups[0][1] == null;
subgroups[0][2] == null;
subgroups[1][0] == null;
subgroups[1][1] == null;
subgroups[1][2] == null;

The values from the deeply nested array don’t get passed. Firebug reports the parameters of my ajax request are:

subgroups[0][0][] A
subgroups[0][0][] Y
subgroups[0][1][] B
subgroups[0][1][] Y
subgroups[0][2][] C
subgroups[0][2][] Y
subgroups[1][0][] D
subgroups[1][0][] Z
subgroups[1][1][] E
subgroups[1][1][] Z
subgroups[1][2][] F
subgroups[1][2][] Z

It looks like the cause is that jQuery isn’t filling in these array indexes because I can fix the problem is I format the data as:

subgroups [0] = [{ 0: "A", 1: "Y"}, ...];

Why does jQuery put the indexes for the outer array, but not the inner one? Please tell me there is a better workaround for this than to manually specify numeric keys?

  • 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-16T12:20:20+00:00Added an answer on May 16, 2026 at 12:20 pm

    in file “code.jquery.com/jquery-1.4.2.js” in line 5290:

    buildParams( prefix + "[" + ( typeof v === "object" jQuery.isArray(v) ? i : "" ) + "]", v );
    

    I change for this code:

    buildParams(prefix + (typeof v === "object" jQuery.isArray(v) ? "[" + i + "]" : ""), v);
    

    and the result was good. I could not test on many more cases.

    I create a ticket in jQuery.com to see if this is a bug:
    Ticket #6900 (new bug)

    but in:

    public ContentResult Action(List<string[][]> subgroups) {
    

    for this modification, you have to use this code:

    public ContentResult Action(List<string[]> subgroups) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying pass in a url as a paramter to my controller like this:
Hey I would like to use Nested Stored Procedures in ASP.NET 2. The first
I am trying to pass the fullcalendar events to my controller via Json, however
I am trying to pass a simple JSON object to a controller using MVC3
I'm trying to pass a value to Page.Title in a nested WebForms Master Page,
I am trying to basically recreate the functionality of an ASP.NET master page with
Im trying to pass some variables from the URL to the PHP script. Now
This is probably a basic OO question: I'm trying to do a nested console
I am trying pass class as value in hashmap. I need to get the
Trying to pass the root of my Binary Search Tree (BST) to the UI

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.