jQuery 里的 Promise

1  $.ajax("test.html").done(function(){ alert("哈哈,成功了!"); }).fail(function(){ alert("出错啦!"); }).done() ;
    回调函数可以添加任意多个,它们按照添加顺序执行。
 
2
 
 $.when($.ajax("test1.html"), $.ajax("test2.html"))
 
  .done(function(){ alert("哈哈,成功了!"); })
 
  .fail(function(){ alert("出错啦!"); });
posted @ 2019-01-27 20:05  jason_xiao  阅读(146)  评论(0编辑  收藏  举报