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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:58:01+00:00 2026-05-19T11:58:01+00:00

I post $(‘#myForm’).serializeArray() to an ASP.NET MVC (2.0) action. serialized array looks as follows:

  • 0

I post $('#myForm').serializeArray() to an ASP.NET MVC (2.0) action.
serialized array looks as follows:

filters[0][name]    : gemcolor
filters[0][value]   : Yellow
filters[1][name]    : gemcolor
filters[1][value]   : Green
filters[2][name]    : jcOnly
filters[2][value]   : true
someOtherData       : abc

I want to have that consumed in:

public ActionResult GetData(Filter filter)

class Filter {
    string someOtherData;
    bool jcOnly;
    List<string> gemcolor;
}

I can just dig through FormCollection, but I am looking for a more elegant solution (I suspect it will involve a custom model binder).

  • 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-19T11:58:02+00:00Added an answer on May 19, 2026 at 11:58 am

    This won’t work because the default model binder doesn’t expect the data to be formatted like this. Simply use .serialize() instead of serializeArray(). Example:

    $.ajax({
        url: '/foo',
        type: 'post',
        data: $('#myForm').serialize(),
        success: function(result) {
            alert('ok');
        }
    });
    

    or simplify your life by using the excellent jquery form plugin which allows you to AJAXify existing HTML forms in an elegant manner:

    $(function() {
        $('#myForm').ajaxForm(function(result) {
            alert('ok');
        });
    });
    

    UPDATE:

    After the explanation in your comment here’s how you could proceed:

    You could use the plugin from this answer which transforms the form elements into an object understandable by the default model binder and could be aggregated with some other information:

    $.fn.serializeObject = function()
    {
        var o = {};
        var a = this.serializeArray();
        $.each(a, function() {
            if (o[this.name]) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return o;
    };
    

    and then simply:

    data: { filters: $('#myForm').serializeObject(), someOtherData: 'foo bar'  }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Post looks like this. $data = array('icd9' => $icd9, 'cpt' => $cpt, 'session_id'=>
post '/upload' do unless params[:file] && (tmpfile = params[:file][:tempfile]) && (name = params[:file][:filename]) return
My Post model in schema.yml (Symfony 1.4) looks like this: Post: columns: id: {
post (id_post, title) tag (id_tag, name) post_tag (id_post_tag, id_post, id_tag) Lets suppose that id_post
Every post has only one category, and i need to access category's name by
// Post model return array( 'categories' => array(self::MANY_MANY, 'Category', 'categories_posts(post_id, category_id)') ); I already
I post some parameters to a PHP page and return some message, looks like
Post to wall from Android application... parameters.putString(app_id, mAppId); parameters.putString(picture, http://fbrell.com/f8.jpg); parameters.putString(name, Facebook Dialog); parameters.putString(caption,
Post :belongs_to :user User :has_many :posts In my signup workflow they draft a Post
POST requests to server work fine until a file is attached. The form is

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.