美文网首页
前台异步传集合到后台,也可以用这种方式接受List

前台异步传集合到后台,也可以用这种方式接受List

作者: 天马行空_9f6e | 来源:发表于2019-03-15 13:07 被阅读0次

前台异步传递

$.ajax({

                            type: "POST",

                            url: "/SystemOrder/InventoryRecord/SubmitForm",

                            data: JSON.stringify(vm.InventoryRecordInfo.List),

                            dataType: "json",

                            success: function (data) {

                                vm.$Notice.success({

                                    title: '成功',

                                    desc: '提交成功'

                                });

                                window.setTimeout(function () {

                                    $.modalClose();

                                }, 1500);

                            }

                        });

后台接收

public ActionResult SubmitForm()

        {

            string result = "";

            try

            {

                var sr = new StreamReader(Request.InputStream);

                var stream = sr.ReadToEnd();

                JavaScriptSerializer js = new JavaScriptSerializer();

                List<SysInventoryRecordEntity> list = js.Deserialize<List<SysInventoryRecordEntity>>(stream);

                sysInventoryRecordApp.SubmitForm(list);

                result = new AjaxResult { state = ResultType.success.ToString(), message = "操作成功。" }.ToJson();

            }

            catch (Exception)

            {

                result = new AjaxResult { state = ResultType.error.ToString(), message = "操作失败。" }.ToJson();

                throw;

            }

            return Content(result);

        }

相关文章

网友评论

      本文标题:前台异步传集合到后台,也可以用这种方式接受List

      本文链接:https://www.haomeiwen.com/subject/yrulmqtx.html