asp.net mvc ajax提交模型到控制器

http://blog.csdn.net/loongsking/article/details/53224473

 

 function btn_submit() {
        var data = null;
        var trList = $("#forecastBillcode tbody").children("tr")
        for (var i = 0; i < trList.length; i++) {
            var tdArr = trList.eq(i).find("td");
            data = {
                model: [{
                    Kd_BillCode: tdArr.find('input[name=Kd_BillCode]').val(),
                    Kd_GoodsName: tdArr.find('input[name=Kd_GoodsName]').val(),
                    Kd_GoodsType: tdArr.find('select[name=Kd_GoodsType] option:selected').val(),
                    Kd_Number: tdArr.find('input[name=Kd_Number]').val(),
                    Kd_Rem: tdArr.find('input[name=Kd_Rem]').val()
                }]
            };
        }
        $.ajax({
            type: "POST",
            url: "/Data/AddPrediction",
            data: JSON.stringify(data),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: false,
            success: function (result) {
                alert(result);
            },
            error: function (result) {
                alert("错误" + result);
            }
        });
    }

 

 

   [ValidateInput(false)]
        public string AddPrediction([FromBody] List<PlatForm.Models.AddPredictionModel> model)
        {
            if (ModelState.IsValid)
            {

            }
            return "asdfasdf";
        }

posted @ 2017-11-16 20:06  LuoCore  阅读(871)  评论(0编辑  收藏  举报