Suk*_*ene -1 javascript c# ajax asp.net-mvc jquery
我有AJAX脚本将数据写入表
这是代码
<script>
$('#save_appointment').click(function () {
addAppointmentInternal();
});
function addAppointmentInternal() {
$.ajax({
type: 'Post',
dataType: 'Json',
data: {
Start: $('#startAppointment').val(),
End: $('#endAppointment').val(),
Title: $('#title').val()
},
url: '@Url.Action("AddingInternalAppointment","Calendar")',
sucess: function (da) {
if (da.Result === "Success") {
alert();
} else {
alert('Error' + da.Message);
}
},
error: function(da) {
alert('Error');
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是后端的代码
public ActionResult AddingInternalAppointment(string Start, string End, string Title)
{
Appointment appointment = new Appointment()
{
Start_appointment = Start,
End_appointment = End,
Title = Title
};
db.Appointments.Add(appointment);
db.SaveChanges();
return Json(new { Result = "Success", Message = "Saved Successfully" });
}
Run Code Online (Sandbox Code Playgroud)
一切都还好.数据写入表格.但我有问题,成功后我没有收到警报信息.
哪里可以有问题?
success:ajax成功的拼写错误.你正在使用成功.检查并纠正它.
更改
sucess: function (da) {
Run Code Online (Sandbox Code Playgroud)
至
success: function (da) {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
439 次 |
| 最近记录: |