が含まれている私はここでAajax要求パラメータ辞書は、パラメータにnullエントリ(ASP.NET)
にDBにデータを追加する方法は、コードは、バックエンド
public ActionResult AddingInternalAppointment(string Start, string End, string Title, DateTime Date,int id)
{
using (var ctx = new ApplicationDbContext())
{
Appointment appointmentInt = new Appointment()
{
Start_appointment = Start,
End_appointment = End,
Title = Title,
Type_of_appointment = "Internal",
Date = Date
};
ctx.Appointments.Add(appointmentInt);
ctx.SaveChanges();
return Json(new {Result = "Success", Message = "Saved Successfully"});
}
}
上にあり、ここにAJAXである必要があり前面に要求 - エンド:私はこの関数を呼び出すと
function addAppointmentInternal() {
var idofdoctor = moment($('#startAppointment').val()).toISOString();
alert(idofdoctor);
$.ajax({
type: 'Post',
dataType: 'Json',
data: {
Start: $('#startAppointment').val(),
End: $('#endAppointment').val(),
Title: $('#title').val(),
Date: moment($('#startAppointment').val()).toISOString()
},
url: '@Url.Action("AddingInternalAppointment","Calendar")',
success: function (da) {
if (da.Result === "Success") {
$('#calendar').fullCalendar('refetchEvents');
$("#myModal2").modal();
} else {
alert('Error' + da.Message);
}
},
error: function(da) {
alert('Error');
}
});
}
それは私に、このエラーを示しているが、私は日中の値を持っています。
どうすれば修正できますか?
に応じ
次のアクションが(何か他にパラメータ名の日付を変更してみてくださいアクション
更新のためのモデルを作成します。 alike appointmentDate)、それはキーワードのように思われるので、パラメータとして使用することはできません。あなたはajax呼び出しで同じものを変更する必要があります。 – DSR
ajaxを呼び出すときに '$( '#startAppointment')。val()'の値は何ですか? – Wndrr
この値に誤りがあります@Wndrr –