gpt4 book ai didi

jquery - ajax 成功但不起作用

转载 作者:行者123 更新时间:2023-12-01 08:41:47 25 4
gpt4 key购买 nike

为什么我的 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'
});
}
});
}
}
});
});
});

Controller

[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.");
}

我实际上可以在检查器的响应选项卡中看到结果为真,并且可以保存在我的数据库中。为什么成功功能不起作用,我无法理解。如果我故意创建一个错误,我可以看到我的错误函数起作用。你能指出我做错了什么吗?

最佳答案

有一个错别字

succes: function (controlResult) {

你能纠正它并尝试使用双s成功

关于jquery - ajax 成功但不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46152591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com