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("出错啦!"); });
相关文章
相关标签/搜索