Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 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