开发者

Tutorial on jQuery Endless/Infinite Scroll and PHP-MySQL [closed]

开发者 https://www.devze.com 2023-01-31 20:48 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

开发者_如何学JAVA Improve this question

I'm looking for a tutorial that breaks down how jQuery's Endless/Infinite Scroll plugin can call data stored in a MySQL database ... presumably with PHP, although I'm a beginner so I may be missing something here.

Everything I've found so far goes into the nitty-gritty of the javascript, or the philosophy of a "pageless web" but does not actually explain how the plugin can be used to de-paginate large query results.

Any help at all is greatly appreciated :)


Refering to this answer you can use jquery to detect when the end of page has been reached...

  $('#col2').scroll(function(){
    if ($('#col2').scrollTop() == $('#col2').height()){
       loadMore();
    }
});

Once you get to the end of the page you can write a method that will do an ajax call to fetch more data, see JQuery AJAX...

$.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
 })

The returned results from your PHP page can then be added onto the bottom of the web page, see JQuery append.

I hope this helps... :)


Just in case anyone is having a problem getting the correct $(document).height, like I did, what I did to solve the problem was on document ready I used var doc = document.documentElement.clientHeight to get the correct height and put it in a variable, then used :if ($(window).scrollTop() >= $(window).height() - + doc + - 100) to establish the condition. I hope this helps someone.


If you are looking for tutorial to implement endless scrolling in php, this can help you. This tutorial uses jscroll and implemented on php website using codeigniter framework on serverside. Tutorial on endless scrolling in php

0

精彩评论

暂无评论...
验证码 换一张
取 消