Link to home
Start Free TrialLog in
Avatar of WorknHardr
WorknHardr

asked on

MVC 5 AJAX Post DIV Form Seriaiaze to Action Model Always Null?

I cannot post Div values to an MVC Action model, always null. I've tried many article examples and still get nulls. Capturing the .serialize in an alert looks like the pic below. I'm not understanding how an MVC Model can accept a serialize object. It looks like a simple querystring...

User generated image
Here's my code so far:

$.ajax({
        url: 'Posts/Save',
        data: $("#form1 :input,text,textarea,select,hidden").serialize(),
        type: 'POST',
        contentType: "application/json; charset=utf-8",
        cache: false,
        success: function (result) {
            alert(result);
        },
        error: function (error) {
            alert("ERROR: " + JSON.stringify(error));
        }

    });

[Action]
 public JsonResult Save(PostUpdateViewModel model)
 {
 }
ASKER CERTIFIED SOLUTION
Avatar of Gary Davis
Gary Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WorknHardr
WorknHardr

ASKER

I found another post where they added these properties to Ajax and it started working:

   $.ajax({
         url: 'Posts/Save',
         data: $("#form1 :input,text,textarea,select,hidden").serialize(),
         type: 'POST',
         cache: false,
         contentType: false,
         processData: false,

         success: function (result) {
             alert(result);
         },
         error: function (error) {
             alert("ERROR: " + JSON.stringify(error));
         }
     });
Thanks for your help. I found the answer elsewhere...