JS代码
1 var serializer = new JSONSerializer(); 2 var model = serializer.Serialize($("#StudentsSchoolCertificate")[0]); 3 model.type = 2; 4 $.ajax({ 5 type: "get", 6 url: "/Handler/StudentsSchoolCertificateHandler.ashx", 7 dataType: "json", 8 data: model, 9 async: true, 10 success: function (result) { 11 if (result.ReturnType) { 12 alert("保存成功!"); 13 } else { 14 alert("获取失败!"); 15 } 16 } 17 });
服务端代码C#
1 private ResultMessage Add(HttpContext context) 2 { 3 try 4 { 5 SerializerHelper serializer = new SerializerHelper(); 6 UserUserSchoolModel model = serializer.DeserializeFromRequest<UserUserSchoolModel>(context.Request); 7 model.CreateTime = DateTime.Now; 8 int result = UserUserSchoolBpl.Add(model); 9 return new ResultMessage(result > 0, result > 0 ? "保存成功!" : "保存失败!", result.ToString()); 10 } 11 catch (Exception ex) 12 { 13 return new ResultMessage(false, "保存失败!", ex.Message); 14 } 15 }
时间: 2025-01-02 23:58:56