Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2015-02-06
1
Medium Priority
?
658 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 2000 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

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

Question has a verified solution.

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

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 article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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