//捲到底次數(像分頁一樣) var sindex; $(function () { //begin get data from 1. sindex = 1; showDetial(sindex); $(window).scroll(function () { var $BodyHeight = $(document).height(); var $ViewportHeight = $(window).height(); $ScrollTop = $(this).scrollTop(); if ($BodyHeight == ($ViewportHeight + $ScrollTop)) { //scroll bar then add search index. sindex++; //get data. showDetial(sindex); } }); //avoid click F5 when scrollerbar not in bottom then default run scroll that have same data, so this check user if click buttom that scroll to top. $(window).keydown(function (e) { //e.which code 116 = F5. if (e.which == 116) { $('html, body').scrollTop(0); } }); }); //get data function showDetial(sindex) { $.ajax({ url: " / ", type: 'POST', data: { page: sindex },