为什么我的Ajax成功代码无效。
查看
$.connection.hub.start().done(function() {
// Populate the object with values
$(document).on("click", "#btn_submit_schedule", function () {
bootbox.confirm({
title: "Save these details?",
message: html,
buttons: {
confirm: {
label: 'YES',
className: 'btn-success'
},
cancel: {
label: 'NO',
className: 'btn-danger'
}
},
callback: function (result) {
if (result === true) {
$.ajax({
type: 'POST',
url: '/Member/CreateTicket',
data: obj,
succes: function (controlResult) {
console.log(controlResult);
if (controlResult === true) {
$.notify({
icon: 'glyphicon glyphicon-star',
message: "Ticket has been saved"
}, {
animate: {
enter: 'animated bounceIn',
exit: 'animated bounceOut'
}
}, {
type: 'success'
});
$("#create_ticket_status").html("Created ticket successfully.");
chat.server.getPendingRequestCount(document.getElementById("selected_id").value);
} else {
$("#create_ticket_status").html(result);
$.notify({
icon: 'glyphicon glyphicon-star',
message: "An error has occured on creating the ticket"
}, {
animate: {
enter: 'animated bounceIn',
exit: 'animated bounceOut'
}
}, {
type: 'success'
});
}
},
error: function() {
$.notify({
icon: 'glyphicon glyphicon-star',
message: "Error has occured in creating ticket."
}, {
animate: {
enter: 'animated bounceIn',
exit: 'animated bounceOut'
}
}, {
type: 'success'
});
}
});
}
}
});
});
});
控制器
[HttpPost]
public ActionResult CreateTicket(CreateTicket ticket)
{
if (ModelState.IsValid)
{
var tm = new TicketManager();
var controlResult = tm.CreateTicket(ticket);
return controlResult ? Json(true) : Json("An error occured on creating the ticket.");
}
return Json("Fill-in the required fields.");
}
我实际上可以在检查器的响应选项卡中看到结果为true,我可以保存在我的数据库中。为什么成功功能不起作用,超出我的范围。 如果我故意创建错误,我可以看到我的错误函数有效。你能指出我做错了吗?
答案 0 :(得分:2)
有一个错字
成功:函数(controlResult){
你可以纠正它并尝试使用double s 成功