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("出错啦!"); });

猜你喜欢

转载自www.cnblogs.com/jason-beijing/p/10327786.html
今日推荐