function answerTheQuestion(id) {
swal({
title: "enter complaint",
input: "textarea",
showCancelButton: true,
confirmButtonColor: "#DD8B11",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}).then(function(text) {
$.ajax({
type: "POST",
url: "../ajax/ajax_active_deact.php?type=complaint_answered",
data: {complaint_id: id, myContentText: text},
cache: false,
success: function(response) {
swal(
"success!",
"your note has been saved!",
"success"
)
},
failure: function(response) {
swal(
"Internal error",
"oops, your note was not saved",
"error"
)
}
});
},
function(dismiss) {
if(dismiss === "cancel") {
swal(
"Cancelled",
"cancelled note",
"error"
)
}
});
}
<button class='btn btn-xs btn-info2' onclick='answerTheQuestion($complaint->complaint_id)' data- tooltip='tooltip' title='open the form for answered the complaint' >
<i class='ace-icon fa fa-edit bigger-120'></i>
</button>
答案 0 :(得分:0)
我发现您的代码中缺少的一些东西是:
1)将csrf_token发送到带有怨言ID和myContentText的数据中。
2)投诉编号必须以逗号分隔。
3)myContentText必须为反引号。
如果swal({})。then(function(){})不起作用,请尝试使用swal({},function(){})。