且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

首先jQuery的Ajax调用与第二碰撞

更新时间:2023-11-20 23:49:16

返回的承诺, $。阿贾克斯内部返回。

Return the promise that $.ajax returns internally.

function loadPosts(skip, take, container) {
   return $.ajax({ /* options left out for brevity */})
}

然后可以使用一审承诺回调初始化第二个

Can then use promise callback of first instance to initialize second

loadPosts(skip, take, $postContainer).done(function(){
    loadPosts(0, 10, $recentPostContainer);
});