基本概念
鏈式編程:設計模式之一
DEMO
doSubmit: function(){
return $.ajax({
url: url,
type: 'post',
data: $("#fm").serialize(),
dataType: 'html'
}).then(function(data){
toastr.error(" 提交成功", "操作成功");
}, function(){
toastr.error("提交失敗", "操作失敗");
});
}
$.ajax("test.html")
.done(
function(){
console.log("success");
}
)
.fail(
function(){
console.log("error");
}
);
$.when($.ajax("test1.html"), $.ajax("test2.html"))
.done(function(){console.log("success");})
.fail(function(){console.log("error");});
參考文章
https://blog.csdn.net/qq_27970999/article/details/78718023
https://blog.csdn.net/zhouziyu2011/article/details/70257687
https://blog.csdn.net/weixin_33935505/article/details/89527694