Ajax PHP自动加载滚动和网格样式的内容

时间:2014-04-24 00:20:49

标签: ajax grid autoload

我已成功使用以下代码创建自动加载内容:

<script type="text/javascript">
            $(document).ready(function() {
                var track_load = 0; //total loaded record group(s)
                var loading  = false; //to prevents multipal ajax loads
                var total_groups = <?php echo $total_groups; ?>; //total record group(s)

                $('#results').load("autoload_process.php", {'group_no':track_load}, function() {track_load++;}); //load first group

                $(window).scroll(function() { 
                    if($(window).scrollTop() + $(window).height() == $(document).height()){         
                        if(track_load <= total_groups && loading==false){
                            loading = true; //prevent further ajax loading
                            $('.animation_image').show(); 
                            $.post('autoload_process.php',{'group_no': track_load}, function(data){
                                $("#results").append(data); 
                                $('.animation_image').hide(); 
                                track_load++; //loaded group increment
                                loading = false; 
                            }).fail(function(xhr, ajaxOptions, thrownError) { 
                                alert(thrownError); //alert with HTTP error
                                $('.animation_image').hide(); //hide loading image
                                loading = false;
                            });                         
                        }
                    }
                });
            });
        </script>
你可以帮我制作像portofolio这样的网格风格吗? 喜欢这个网站:http://www.clear.co.id/

0 个答案:

没有答案