示した例の1つは、ASP.NETを含むすべてのサーバー側テクノロジでうまく機能する可能性があります。
開始するための基本的なHTML:
<div id="posts">
<div class="item">Starting content</div>
<div id="loadmore" style="display: none"><img src="ajax-loader.gif" alt="Loading..." /></div>
</div>
そして、jQueryコードの小さな部分(それを行うためのプラグインは必要ありません):
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
$("#loadmore").show();
$.ajax({
url: "loadmore.aspx",
contentType: "text/html; charset=utf-8"
).done(function(html) {
if (html) {
$("#posts").append(html);
$("#loadmore").hide();
} else
$("#loadmore").html("No more posts to show.");
});
}
});
ASPXコードはHTMLとしてレンダリングされるため、コンテンツは#postsラッパーに直接追加できます。もちろん、コードを少し調整して、ASPXにいくつかのパラメーターを渡して、取得する投稿の数と、どの投稿から開始するかを知る必要があります...しかし、クライアント側のコードは、ここではもう問題ではありません。