$(window).scroll(function () { var wScrollTop = $(window).scrollTop(); var offsetHeight = 10; var docHeight = $(document).height(); var wHeight = $(window).height(); // console.log("wHeight:" + wHeight); // console.log("offsetHeight:" + offsetHeight); // console.log("docHeight:" + docHeight); // console.log("tarHeight:" + tarHeight); if (wScrollTop >= docHeight - wHeight) { $.mobile.showPageLoadingMsg(); gobalPage++; $.ajax({ type: "POST", url: "http://localhost:58300/handle.aspx", data: "fnName=getContentData&author=haoxinqing&page=" + gobalPage, dataType: "jsonp", jsonpCallback: "hxqContent", success: function (msg) { console.log(msg); $.mobile.hidePageLoadingMsg(); //$.mobile.changePage($("#main"), "slide"); $("#contentList").append(msg.content); $('#contentList').listview('refresh'); } }); } if (wHeight == 0) { //javatranster.getlastData(); //console.log(666); } });
滚到底部加载,应该一看就明白了,里面几个变量的意思。