Pass multiple JSON objects to MVC3 action method

前端 未结 2 1343
天涯浪人
天涯浪人 2020-12-28 18:42

JQuery code:


    //This passes NULL for \"CategoryID\", \"CategoryName\", \"ProductID\", \"ProductName\"
     $(\"#btnPost\").click(function () {
            var         


        
2条回答
  •  感情败类
    2020-12-28 19:02

     var a = $("#a").serialize();
                var b = $("#b").serialize();
                var c = $("#c").serialize();
    
    
         $.ajax(
                {
                    url: '@Url.Content("~/Controller/Method1")',
                    type: 'POST',
                    data: a+b+c,
        success: function (success) {
        // do something
        }
    
        });
    
        // in Controller
        [HttpPost]
        public ActionResult Method1(abc a, bcd b, xyz c)
        {
        }
    
    // where abc, bcd xyz are class
    

提交回复
热议问题