I am trying to use ajax in my view in order to update changes in users profiles. Unfortunately, whatever I try, I get the error message "Error!!!". I think the problem is my model, and I have tried to customize it, but it still does not work.

Here is the JS that is executed when the user pushes the "save" button:

$(document.getElementById('save')).on("click", function() {
            var liSportMotives = $('#sortable li').map(function(i, n) {
                return $(n).attr('id');
            var liActivities = $('#myCarousel div').map(function(i, n) {
                if ($(n).hasClass('thumbnailActive')) {
                    return $(n).attr('id');
            var myPostJSONObject = {
            Weight : parseFloat($(document.getElementById('weightrange')).val()).toFixed(1),
            Height : parseFloat($(document.getElementById('heightrange')).val()).toFixed(2),
            IsSportsBeginnerPractise : $("input:radio[name='IsSportsBeginnerPractise']:checked").val(),
            IsSportsBeginnerKnowledge : $("input:radio[name='IsSportsBeginnerKnowledge']:checked").val(),
            IsNutritionBeginnerPractise : $("input:radio[name='IsNutritionBeginnerPractise']:checked").val(),
            IsNutritionBeginnerKnowledge : $("input:radio[name='IsNutritionBeginnerKnowledge']:checked").val(),
            NewSportMotives : liSportMotives,
            NewActivities : liActivities
                url: '@Url.Action("ManageConfirmation", "Account")',
                type: "POST",
                traditional: true,
                data: JSON.stringify(myPostJSONObject),
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                error: function () {

My model in my controller looks like this:

public class ManageUserDetails
            public decimal Height { get; set; }

            public decimal Weight { get; set; }

            public bool IsSportsBeginnerPractise { get; set; }

            public bool IsSportsBeginnerKnowledge { get; set; }

            public bool IsNutritionBeginnerPractise { get; set; }

            public bool IsNutritionBeginnerKnowledge { get; set; }

            public String[] NewSportMotives { get; set; }

            public String[] NewActivities { get; set; }

And I have an action that looks like this:

    public ActionResult ManageConfirmation(ManageUserDetails model)
        return RedirectToAction("Index", "Home");

Related posts

Recent Viewed