1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="gb2312"> <title>滚动条到底部时自己加载新的内容</title> <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> <script type="text/javascript"> var page_num=2; $(document).ready(function(){ $(window).scroll(function(){ if($(document).scrollTop()>=$(document).height()-$(window).height()){ var div1tem = $('#container').height() var str ='' $.ajax({ type:"GET", url:'ajaxdata.php', dataType:'json', beforeSend:function(){ $('.ajax_loading').show() }, success:function(ret){ $(".after_div").before(ret) $('.ajax_loading').hide() } }) } }) }) </script> </head> <body> <div> <div style='width:100%;height:1200px'>文章内容</div> <div class='after_div'></div> <div class='ajax_loading' style='background:#F0F0F0;height:60px;width:100%;text-align:center;line-height:60px;font-size:18px;display:none;position:fixed;bottom:0px'> <img src="img/loadinfo.net.gif"> 数据加载中 </div> </div> </body> </html>
|