Solved

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

Posted on 2015-02-06
1
595 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
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now