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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:53:34+00:00 2026-05-22T11:53:34+00:00

Does the model binder not suport arrays of JSON objects? The code below works

  • 0

Does the model binder not suport arrays of JSON objects? The code below works when sending a single JSON domain object as part of the ajax post. However, when sending an array of JSON domain objects, the action parameter is null.

     var domains = [{
                        DomainName: 'testt1',
                        Price: '19.99',
                        Available: true
                    }, {
                        DomainName: 'testt2',
                        Price: '15.99',
                        Available: false
                    }];

                $.ajax({
                    type: 'POST',
                    url: Url.BasketAddDomain,
                    dataType: "json",
                    data: domains,
                    success: function (basketHtml) {

                    },
                    error: function (a, b, c) {
                        alert('A problem ocurred');
                    }
            });

This is the action method:

public ActionResult AddDomain(IEnumerable<DomainBasketItemModel> domain)
{
    ...

Any ideas if it is possible to do this?

EDIT

@Milimetric

Your solution works! However, this is my fault, but the code I demonstrated isn’t the real code of my problem, I was trying to show equivalent code that is easier to understand.

I am actually creating an array, then interating some DOM elements and pushing a JSON object onto the array, then posting this array as the data…

var domains = [];

                $(this).parents('table').find('input:checked').each(function () {
                    var domain = {
                        DomainName: $(this).parent().parent().find('.name').html(),
                        Price: $(this).parent().parent().find('.price span').html(),
                        Available: $(this).parent().parent().find('.available').html() == "Available"
                    }

                    domains.push(domain);
                });

                $.ajax({
                    type: 'POST',
                    url: Url.BasketAddDomain,
                    dataType: "json",
                    data: { domain: domains },
                    success: function (basketHtml) {

                    },
                    error: function (a, b, c) {
                        alert('A problem ocurred');
                    }
                });
  • 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-22T11:53:34+00:00Added an answer on May 22, 2026 at 11:53 am

    You need:

    var domains = { domains: [... your elements ...]};
    
                $.ajax({
                    type: 'post',
                    url: 'Your-URI',
                    data: JSON.stringify(domains),
                    contentType: "application/json; charset=utf-8",
                    traditional: true,
                    success: function (data) {
                        ...
                    }
                });
    

    In general, check out the Request object in the debugger, you’ll see what’s being passed and get an idea of how to “speak” HTTP.

    NOTE: Just found this out. The model binder chokes on nullable decimal properties like:

    public decimal? latitude { get; set; }
    

    So it won’t bind that if you’re posting to it with a json string that looks like this:

    {"latitude":12.0}
    

    But it WILL work if you post something like this:

    {"latitude":"12.0"}
    

    See: http://syper-blogger.blogspot.com/2011/07/hello-world.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the memory model for concurrency in C++03? (And, does C++11 change the
In ASP.NET MVC, how does the controller pass information between the model and the
I see this in a stack trace: myorg.vignettemodules.customregistration.NewsCategoryVAPDAO.getEmailContentByID(I)Lmyorg/pushemail/model/EmailContent; What does the (I)L mean?
Does anybody know a good Emacs mode to edit JSON? An app I am
I'm using DataAnnotations attributes to validate my model objects. My model class looks similar
This is my custom model binder. I have my breakpoint set at BindModel but
I use custom model binder to bind Order/OrderItem in my actions. This model binder
I'd like to create a custom model binder. Let's say there're 20 properties. I
Does anybody know how I can close all modal dialogs created by Dojo ?
What are the cases where you'd use a modal popup ? Does it interrupt

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.