我有一个应用程序,我们正在使用实体框架并在按钮上单击一个 ajax 调用来保存值。
一切正常,但即使我们尝试单击保存按钮,没有任何值,它也会在数据库中保存为 null 或空(占用空间)。
我忽略了一些小错误,请帮助我。
我尝试了什么:
$.ajax({
type: "POST",
url: '~/SaveGroups',
data: {
GroupId: (GroupId == null ? -1 : GroupId),
counterId: (counterId == null ? -1 : counterId),
GroupCode: GroupCode,
GroupDesc: GroupDescription
},
success: function (result) {
if (result != null) {
$("#PartialGroupsTable").html(result.GroupsPageString);
$("#GCode").val('') //GCode is the name of the textbox
$("#GDescription").val(''); //GDescription is the other textbox
GroupId = -1;
}
},
complete: function () {
$("#GCode").empty();
$("#GDescription").empty();
},
error: function () {
alert("Details Not Saved. Please try again later");
}
});
提前谢谢。