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()