ajax请求.net后台接收

js

function upOne() {
            var check_val = [];
            var cId = document.getElementById("updateClassIdOne").value;
            console.log(cId);
            var UpdateClass = {
                id: cId,
                userId: $("#OneUpdate").val(),
                organId: cId,
                        title: "学生"
            }
            check_val.push(UpdateClass);
            console.log();
              $.ajax({
                url: "/School/updateUserClass",
                data: {
                    userModel: check_val
                },
                type: "Post",
                dataType: ‘json‘,//必须
                success: function (r) {
                    alert(r.result.msg);
                    location.reload();
                },
            });
        }

后台

public async Task<JsonResult> updateUserClass(List<UserOrganEditDto> userModel)
        {
            try
            {
                await _organUserAppService.BatchUpdateUserOrgan(userModel);
                return Json(new { success = true, msg = "分班成功" });
            }
            catch (Exception ex)
            {

                return Json(new { success = false, msg = "分班失败" });
            }

        }

相关推荐