Solved

MVC Form Serialize Passing List<ViewModel> to Ajax Post seems to not be working?

Posted on 2015-02-06
1
633 Views
Last Modified: 2015-02-10
Hello all,

I have a MVC view that I use an Ajax post which is working great with a Form.Serialize but one of the properties in the view model is a list such as List<MyViewModel>  entries.    When I make a call to the controller create a new List<MyViewModel> pass it to the view its there but on the Ajax Post it seems to either be null or 0 for the count.   Any idea why that would happen, should it not be passed like the other string view model get; set; properties etc?

Thanks all

Here is the Ajax post:
$(document).on('click', '.addDataEntry', function () {

                var $form = $("#portfolioMVForm");
                var serializedData = $form.serialize();
                var url = '@Url.Action("AddPortfolioMarketValueEntry", "Portfolio")';

            $.ajax({
                type: "POST",
                url: url,
                data: serializedData,
                dataType: 'json',
                success: function (data) {
                    $('#PortfolioMVEntryContent').html(data.PartialView);
                },
            });
        }

Open in new window

0
Comment
Question by:sbornstein2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
Gary Davis earned 500 total points
ID: 40596008
Use the F12 Developer Tools Network capture to view the POSTed data and the content response and verify they data is ok. Also, you can put a breakpoint on line 13 to view the data object is as expected.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question