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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:06:49+00:00 2026-05-23T09:06:49+00:00

I am having trouble to pass the serialized js object to controller and let

  • 0

I am having trouble to pass the serialized js object to controller and let the default model binder automtatically deserialize it into my object.

I can manually deserialize the value into my object, it’s all fine. but I would like to know why it doesn’t work.

Thanks

Here is my code snippet

js code

$.post('/Order/AddRecordAddHocStock2', { idPatient: $patientId, "orderItems": JSON.stringify($orderItems) }, function (data) {
                //$("#recordingdialog").html(data).dialog("open");

                var $dialog = $("#popup_dialog2");

                $dialog.empty();
                $dialog
                .dialog({
                    bgiframe: true,
                    title: $title,
                    height: 700,
                    width: 650,
                    modal: true,
                    autoOpen: false,
                    resizable: false
                });

                $dialog.html(data).dialog("open");

            });

Here is the post value get it from firefox

idPatient   72
orderItems     [{"Id":0,"ProductName":"01870","Quantity":0,"StockOnHand":0,"MaxAllowance":12,"OrderTotal":0},{"Id":0,"ProductName":"01870","Quantity":0,"StockOnHand":0,"MaxAllowance":1,"OrderTotal":0}]

Here is my controller which I expected the orderItems should be automatically populate the value from the previous js object

        [HttpPost]
    public virtual ActionResult AddRecordAddHocStock2(long idPatient, List<OrderItemModel> orderItems)
    {
       var items = Request.Form["orderItems"];
       //it's working if I manually deserialize the js object
       var data = new   JavaScriptSerializer().Deserialize(items,typeof(List<OrderItemModel>));
    }
  • 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-23T09:06:49+00:00Added an answer on May 23, 2026 at 9:06 am

    You need to set the content-type to “application/json”. See this blog post for more details. Focus on the jQuery code sample, not the server side changes which are unnecessary in ASP.NET MVC 3: http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx

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

Sidebar

Related Questions

I'm having trouble working out how to pass in arguments into transactions when using
I'm having trouble with nontype(int variable) template parameter. Why can't I pass a constant
I'm having trouble figuring out how I can take a string of an object
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
I'm having trouble with some MSTest unit tests that pass when I run them
I am having trouble trying to pass an valuable after the user fail the
I'm having trouble figuring out how to access a cookie from a compiled object.
I am having trouble trying to pass an extra variable in the url to
I am having trouble understanding how I can effectively and efficiently building a mocking
I'm having trouble describing this issue, which is probably why I can't find the

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.