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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:03:22+00:00 2026-05-24T17:03:22+00:00

I am trying, and struggling, to send an array via JSON to a MVC

  • 0

I am trying, and struggling, to send an array via JSON to a MVC controller action.

Here is what I have and what i’ve tried…

//Get checked records
var $checkedRecords = $(':checked'); //e.g. 3 rows selected = [input 4, input 5, input 6]

//Have tried following:
sendingVar: $checkedRecords.serializeArray(); // gives array of 0's
sendingVar: JSON.stringify($checkedRecords); // gives "{\"length\":1,\"prevObject\":{\"0\":{\"jQuery1313717591466\":1,\"jQuery1313717591653\":13},\"context\":{\"jQuery1313717591466\":1,\"jQuery1313717591653\":13},\"length\":1},\"context\":{\"jQuery1313717591466\":1,\"jQuery1313717591653\":13},\"selector\":\":checked\",\"0\":{}}"...wtf

//Post
$.post(url, { sendingVar: sendingVar }, function(data) {alert(data); });

How do I do it ?

edit: to those that suggest sending $checkedRecords “as is” from the top line – that is not working. I get a strange exception somewhere in the jquery framework 🙁

uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://.../.../.../jquery-1.4.4.min.js :: <TOP_LEVEL> :: line 141" data: no]

which I think means it is attempting to assign null to something it cannot.

Edit: i’m using MVC2 not 3

Edit2: After @Monday’s answer- the problem is due to how I have built the array like [input 4, input 5, input 6] and not [4,5,6] – any ideas how I can just get the values in the array instead ?

Edit3: Stop voting up duplicate when it’s not. Did you actually read my problem or read the problems linked? this is a different issue

@Daveo:

I don’t want to build in an overriding custom attribute just to send an array from JSON, that is rediculous as we’ve already covered in this question-it is not necessary.

MVC3 – irrelevant

  • 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-24T17:03:23+00:00Added an answer on May 24, 2026 at 5:03 pm

    Here is my demo,use mvc2,hope some helps~

    The key to success is traditional

    set the traditional parameter to true

    $(function(){
        var a = [1, 2];
        $.ajax({
           type: "POST",
           url: "<%= ResolveUrl("~/Home/PostArray/") %>",
           data: {orderedIds: a},
           dataType: "json",
           traditional: true,
           success: function(msg){alert(msg)}
        });
    })
    

    Since jquery 1.4 this parameter exists because the mechanism to serialize objects into query parameters has changed.

    and action is~

    [HttpPost]
    public ActionResult PostArray(int[] orderedIds)
    {
        return Content(orderedIds.Length.ToString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send JSON information to jqgrid via Perl, however I'm struggling on
I'm struggling with trying to sort an array of dictionaries. My dictionaries have a
I've been struggling with trying to get my commandButtons to perform an action (yet
I have been struggling with trying to send an email with an attachment using
I'm struggling trying to make a cron job run. Here is what I have:
Happy coding weekend to everyone!!!. I'm stuck trying to send a JSON object via
I'm struggling a lot trying to get our build server going. I am currently
Have been struggling with Javascript closure for a while trying to wrap brain around
I'm trying to get into C++ programming, and I'm quite struggling against the little
I'm trying to make some text bold using HTML, but I'm struggling to get

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.