jQuery $ .post成功函数永远不会触发

Pro*_*ion 3 javascript ajax jquery

我有一个$ .post使用Fiddler我可以看到总是成功发布但我的成功函数永远不会被解雇.

成功发布到url的帖子返回1或者失败返回0,每次我测试它都会返回预期值1,所以我迷失了我做错了什么?

if ($('#mycheckbox').prop('checked')) {
    $.post('/base/MailingList/Subscribe/',
        {
            listId: $('#mycheckbox').val(),
            name: $('#subscriber-name').val(),
            email: $("#subscriber-email").val()
        },
        function(response) {
            console.log(response);
        });
}
Run Code Online (Sandbox Code Playgroud)

Zek*_*erg 8

将另一个函数作为最终回调.该功能将在故障情况下运行.

jquery建议的方式是这样的:

var jqxhr = $.post( "example.php", function() {
   alert( "success" );
})
.done(function() {
    alert( "second success" );
})
.fail(function() {
    alert( "error" );
})
.always(function() {
    alert( "finished" );
 });
Run Code Online (Sandbox Code Playgroud)