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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:09:30+00:00 2026-06-07T03:09:30+00:00

I have an javascript array like this: var optionArray = new Array(); optionArray[totalBankAmount] =

  • 0

I have an javascript array like this:

var optionArray = new Array();
optionArray["totalBankAmount"] = $("#totalBankAmountID").val();
optionArray["singlePlayerAmount"] = $("#singlePlayerAmountID").val();
..... (more array data)

I am sending this Array like this into StartOption (a MVC3 Controller):

$.ajax({
        url: "/StartOption/Index/",
        data: { allOptions: JSON.stringify(optionArray) },
        cache: false,
        type: "POST",
        timeout: 10000,
        dataType: "json",
        success: function (result) {
            ....
        }
});

How Index Action will catch that optionArray ? how i get those data by there array index name into my Index action ?

Please give me a good example, I am new in MVC3.

and sorry for my bad English.

  • 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-07T03:09:32+00:00Added an answer on June 7, 2026 at 3:09 am

    I have an javascript array like this:

    No, you don’t have an array. Arrays in javascript must have zero based integer indexes. What you have is a javascript object.

    So there are 2 scenarios:

    • You want to work with objects
    • You want to work with arrays

    Let’s cover the objects scenario first. So you have an object:

    public class Foo
    {
        public string Bar { get; set; }
        public string Baz { get; set; }
    }
    

    and then you want to pass it to a controller action:

    [HttpPost]
    public ActionResult Index(Foo foo)
    {
        ...
    }
    

    here’s how the calling code might look like:

    var foo = {};
    foo['bar'] = 'some bar';
    foo['baz'] = 'some baz';
    
    // or the equivalent:
    // var foo = {};
    // foo.bar = 'some bar';
    // foo.baz = 'some baz';
    
    // or the equivalent:
    // var foo = { bar: 'some bar', baz: 'some baz' };
    
    $.ajax({
        url: '@Url.Action("index", "startoption")',
        contentType: 'application/json',
        data: JSON.stringify({ foo: foo }),
        type: 'POST',
        timeout: 10000,
        success: function (result) {
            ....
        }
    });
    

    And the second case, with arrays:

    [HttpPost]
    public ActionResult Index(Foo[] foos)
    {
        ...
    }
    

    and the calling code:

    var foos = [];
    
    var foo1 = {};
    foo1['bar'] = 'some bar 1';
    foo1['baz'] = 'some baz 1';
    foos.push(foo1);
    
    var foo2 = {};
    foo2['bar'] = 'some bar 2';
    foo2['baz'] = 'some baz 2';
    foos.push(foo2);
    
    // or the equivalent:
    // var foos = [ { bar: 'some bar 1', baz: 'some baz 1' }, 
    //              { bar: 'some bar 2', baz: 'some baz 2' } ];
    
    $.ajax({
        url: '@Url.Action("index", "startoption")',
        contentType: 'application/json',
        data: JSON.stringify({ foos: foos }),
        type: 'POST',
        timeout: 10000,
        success: function (result) {
            ....
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have javascript code some thing like this -- var count=3; var pl=new Array(count);
I have JavaScript code like this: var buffer=new Array(); function fetchData(min,max){ var ajaxReq =
For example, I have JavaScript array like this: var data = [ {text:'Business', aid:'6'},
Let's say you have a JavaScript class like this var DepartmentFactory = function(data) {
I have a javascript array written like this... var json = [ {id:1, title:Test
I have a javascript array like this var array1= [10,20,30,40,50]; Is there any method
I have javascript function return array like this: <script type=text/javascript> function looping() { var
I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new
If I have a javascript object/assoc. array defined like this: function somefunction(options) { var
I have an javascript array, which looks like: var styles = new Array(); styles[0]

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.