解决方法: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("出错啦!"); });
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章