每当用户把滚动条拖到最底端时,就调用getData()方法获取数据,那么,我们需要把getData()方法和滚动条事件进行绑定,具体实现如下:
<p><font size="3"> $(window).scroll(function() {</font></p>
<p><font size="3"> // When scroll at bottom, invoked getData() function.</font></p>
<p><font size="3"> if ($(window).scrollTop() + $(window).height() == $(document).height())
{</font></p>
<p><font size="3"> if (trackLoad.groupNumber <= totalGroups && !trackLoad.loading)
{</font></p>
<p><font size="3"> trackLoad.loading = true; // Blocks other loading data again.</font></p>
<p><font size="3"> $('.animation_image').show();</font></p>
<p><font size="3"> $.getData(trackLoad);</font></p>
<p><font size="3"> }</font></p>
<p><font size="3"> }</font></p>
<p><font size="3"> });</font></p> |
|