解決方法:jquery deferred

參考阮一峯的博客
$.ajax()操作,如果低於1.5.0版本

$.ajax({
    url: "test.html",
    success: function(){
      alert("哈哈,成功了!");
    },
    error:function(){
      alert("出錯啦!");
    }
  });

$.ajax()操作,如果高於1.5.0版本,返回的是deferred對象,可以進行鏈式操作。

$.ajax("test.html")
  .done(function(){ alert("哈哈,成功了!"); })
  .fail(function(){ alert("出錯啦!"); });
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章