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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:23:59+00:00 2026-05-23T06:23:59+00:00

I am trying to submit this with Ajax to a MVC3 controller: var params

  • 0

I am trying to submit this with Ajax to a MVC3 controller:

    var params = {
        'productId': productId,
        'list': []
    };

    $.each($('.specificationId'), function () {
        var specId = $(this).attr('id').replace('specification_', '');

        var specification = {
            specificationId: specId,
            articleId: $('#articleid_' + specId).attr('value'),
            price: $('#price_' + specId).attr('value'),
            stock: $('#stock_' + specId).attr('value'),
            stockCount: $('#stockcount_' + specId).attr('value'),
            weight: $('#weight_' + specId).attr('value'),
            visible: $('#visible_' + specId).attr('checked')
        };

        params.list.add(specification);
    });

    console.log(params);
    //all values are parsed fine here, shows an array with json objects

    $.ajax({
        type: "POST",
        url: "/Admin/Product/Save/",
        data: params,
        success: function () { alert('done'); }
    });

Now this has to go to the controller like so:

    [HttpPost]
    public Boolean Save(Int32 productId, Object[] specifications)
    {

        return true;
    }

But Object[] does not work, returns null, I tried all sorts of stuff like lists of a model etc, but it will stay null.

How to tackle this?

  • 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-23T06:24:00+00:00Added an answer on May 23, 2026 at 6:24 am

    ASP.NET MVC 3 includes built-in JSON model binding.

    So create simple POCOs which matches the JSON your attempting to submit:

    public class ProductJsonModel
    {
       public int ProductId { get; set; }
       public ProductSpecificationJsonModel[] @List { get; set; }
    }
    
    public class ProductSpecificationJsonModel
    {
       public int SpecificationId { get; set; }
       public int ArticleId { get; set; }
       public double Price { get; set; }
       public int Stock { get; set; }
       public int StockCount { get; set; }
       public int Weight { get; set; }
       public bool Visible { get; set; }
    }
    

    Then accept that in your action:

    [HttpPost]
    public Boolean Save(ProductJsonModel model)
    

    As long as the property names in the JSON object match the property names in the POCO’s, MVC will bind for you.

    Also – you should serialise the JSON using .stringify or something similar, and set the contentType of the $.ajax object accordingly.

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

Sidebar

Related Questions

i'm trying to submit my Ajax form using jQuery. However calling the submit() function
I am trying to submit a form using jQuery's .ajax() function. It seems like
I'm trying to submit a form with AJAX through jQuery: $('.submit input').click(function() {return false;});
I am trying to use Ajax Form Submit. In the BeforeSubmit function. i want
I am trying to submit a form via ajax using: $(document).ready(function(){ $(#ajax-form).submit(function(){ $.post( albums.php,
I'm trying to submit a form via ajax to an MVC controller. HTML <%
I'm trying to use the following code to log users in: $(form).submit(function(event) { $.ajax({
Am new to this and just trying to submit dynamically populated select list on
I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something
I am just starting out with ajax...trying to submit a form with ajax through

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.