爲什麼我在Ajax成功上的代碼無法正常工作?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.");
}
其實我可以看到結果爲真在檢查的效應初探選項卡,我可以在我的數據庫保存。爲什麼成功功能不起作用,超越了我。 如果我故意創建一個錯誤,我可以看到我的錯誤功能起作用。你能指出我做錯了什麼嗎?
ü拼寫錯誤更迭,應該是成功 –
@彼得謝謝。 – Ibanez1700
@Rory你是什麼意思?你可以給我看一個樣品或鏈接也許.. – Ibanez1700