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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:22:43+00:00 2026-05-26T13:22:43+00:00

When I send a list of int’s with jQuery like this: $.ajax(‘@Url.Action(Execute)’, { type:

  • 0

When I send a list of int’s with jQuery like this:

$.ajax('@Url.Action("Execute")', {
    type: 'POST',
    data: {
        pkList: [1,2,3]
    }
});

Then jQuery will transform the pkList object and send it by post like this:

pkList[]:1
pkList[]:2
pkList[]:3

Which would be fine if the server is PHP but I use Asp.NET MVC3 and try to get these values with the default model binder:

public ActionResult Execute(ICollection<int> pkList)

But pkList is always null, it seems that the default model binder cannot bind it.

How do I solve this correctly?


ADDED SOLUTION

I used the solution from Darin Dimitrov with setting the traditional option in jQuery:

$.ajax('@Url.Action("Execute")', {
    type: 'POST',
    traditional: true,
    data: {
        pkList: [1,2,3]
    }
});

Now jQuery doesn’t add the [] to the parameters anymore and they are sent like this:

pkList:1
pkList:2
pkList:3

And the MVC default model binder gets the values correctly.

Hope this helps someone.

  • 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-26T13:22:44+00:00Added an answer on May 26, 2026 at 1:22 pm

    You could use a JSON request as it will allow you to send any complex objects you wish:

    $.ajax({
        url: '@Url.Action("Execute")',
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify({ pkList: [1, 2, 3] }), // you could throw any javascript object you like here
        success: function(result) {
            // process the results
        }
    });
    

    The JSON.stringify method is built in modern browsers and if you want to support legacy browsers you could include the json2.js script to your site.

    And to answer your question you could use set the traditional: true option to indicate to jQuery to fallback to traditional serialization of parameters since this has changed in jQuery 1.4 and if you are using a later version you have the possibility to switch back to the way parameters are serialized:

    $.ajax({ 
        url: '@Url.Action("Execute")',
        type: 'POST',
        data: {
            pkList: [1, 2, 3]
        },
        traditional: true
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web service that looks like this [WebMethod] public int Import(System.Collections.Generic.List<Record> importRecords)
I want to send some strings in a list in a POST call. eg:
I have a list that I need to send through a URL to a
I am trying to send a jquery sortable list of items to my MVC
The code: [1] private delegate void ThreadStatusCallback(ReceiveMessageAction action, Dictionary<int, List<string>> message); [2] Dictionary<int, List<string>>
I have a jQuery ajax call in which I am trying to send the
I am attempting to send some data via JSON to a MVC controller action:
I'm currently trying to send data via POST to a server, and the server
I'm using asp.net mvc2 and trying to send a list of json objects with
Possible Duplicate: Upcasting and generic lists Ok, I want to send a List<CardHolder> as

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.