Ajax .done()和.fail()同时触发

时间:2018-12-13 08:29:44

标签: jquery ajax jquery-confirm

当我触发ajax调用时,我正在使用Jquery Confirm,但状态响应为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()仍同时触发

0 个答案:

没有答案