promise捕获错误

function fn(){
            var a = $.Deferred();
            a.reject('hahaha精神工疾');
            return a.promise();
        }

        fn().then(function() {
            console.log('success 1');
        },function (msg) {
            console.log(msg);
        }).then(function() {
            console.log('success 2');
        },function (msg) {
            console.log(msg);
        });
//‘hahaha精神工疾’
//underfined

then的错误执行会传递,但错误信息不传递

then支持延续任务调用方式(Continuation tasks),而done不支持
比如then可以这样用,而done不可以:
promise().then().then().then() 

 

posted @ 2014-09-18 13:54  欧欧欧子  阅读(360)  评论(0编辑  收藏  举报