看到园友的网站(www.evercolour.com 刚联系他,半天也不回复,只好来这里请教了),看到页面下方有个 load more posts 按钮,很感兴趣,谁能给具体解释一下,我还见过,没有按钮的,直接拉到页面下方自动加载的那种,都是用的javascript吧。
看一下源码,比较简单的。
| // Ajax-fetching "Load more posts" | |
| $('.fetch a').live('click', function(e) { | |
| e.preventDefault(); | |
| $(this).addClass('loading').text('Loading...'); | |
| $.ajax({ | |
| type: "GET", | |
| url: $(this).attr('href') + '#boxes', | |
| dataType: "html", | |
| success: function(out) { | |
| result = $(out).find('#boxes .box'); | |
| nextlink = $(out).find('.fetch a').attr('href'); | |
| $('#boxes').append(result).masonry('appended', result); | |
| $('.fetch a').removeClass('loading').text('Load more posts'); | |
| if (nextlink != undefined) { | |
| $('.fetch a').attr('href', nextlink); | |
| } else { | |
| $('.fetch').remove(); | |
| } | |
| } | |
| }); | |
| }); |
从不表现看,就是一个ajax请求,然后append。