Solved

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

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

22 Experts available now in Live!

Get 1:1 Help Now