读书人

jQuery Deferred 回调 最简 课程

发布时间: 2012-11-25 11:44:31 作者: rapoo

jQuery Deferred 回调 最简 教程
Deferrd是jQuery提供的回调方法包装类。

以下内容摘自jQuery Api 1.7



还有一些方便使用的函数:$.when(dfd1,[dfd2,[dfd3]]),他返回的还是Deferrd对象。当传入的所有dfd都成功后,才会触发done事件。当任意一个dfd失败,立即触发fail


// Attach a done, fail, and progress handler for the asyncEvent$.when(asyncEvent()).then(function (status) { //注册成功回调,done    console.log(status + ', things are going well');}, function (status) { //注册失败回调,fail    console.log(status + ', you fail this time');}, function (status) { //注册progress回调。1.7新增    $("body").append(status);});



最后说精彩的代码:http://p2world.iteye.com/blog/1405227

http://p2world.iteye.com/blog/1405238

读书人网 >Web前端

热点推荐