我正在使用Jquery Confirm当我触发我的 ajax 调用时,我得到 200 的状态响应,但我的 .done() 和 .fail() 同时触发。如果收到的响应为 200,我是否正确 .done() 将触发?
var frameid = $('#frameID').val();
$('.change-frame').on('click', function (e) {
e.preventDefault();
$.confirm({
title: 'Changing your Base frame?',
content: 'Let us know what happened to it.<br><span>This will also delete your frame in our database</span>.',
animation: 'scale',
closeAnimation: 'scale',
draggable: false,
buttons: {
'Sold': {
text: 'I sold it',
btnClass: 'btn-dark',
action: function () {
$.ajax({
url: '/base-frame/delete',
data: {frameid},
dataType: 'json',
}).done(function(){
console.log('SUCCESS')
}).fail(function(){
console.log('FAILED')
});
}
},
'Traded': {
text: 'I traded it',
btnClass: 'btn-dark',
action: function () {
$.alert('You Traded your Frame');
}
},
Stolen: {
text: 'It was stolen',
btnClass: 'btn-dark',
action: function () {
$.alert('Sorry to hear that');
}
},
}
});
});
我在这里做错了什么?
更新
试图强制响应 400 但 .done() 和 .fail() 仍然同时触发