facebook like “Load More” on Scrolling | Techbirds

Posted on: February 3, 2014 /

Categories: PHP / Author Name: Shivek Parmar

You may find interesting solutions about the same Post o different websites. One of the solution that you may find in popular www.stackoverflow.com is followong.

jQuery(window).scroll(function() { if(jQuery(window).scrollTop() == jQuery(document).height() – jQuery(window).height()) { // ajax call get data from server and append to the div jQuery.ajax({ type: ‘POST’, url: ‘URL’, data: { }, complete: function( httpResponse, status ) { var response = httpResponse.responseText; var res = jQuery.parseJSON(response); } }); } });

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

    jQuery(window).scroll(function()

    {

        if(jQuery(window).scrollTop() == jQuery(document).height() – jQuery(window).height())

        {

            // ajax call get data from server and append to the div

            jQuery.ajax({

            type: ‘POST’,

            url: ‘URL’,

            data: {  },

            complete: function( httpResponse, status )

            {

                var response = httpResponse.responseText;

                var res = jQuery.parseJSON(response);

            }

            });  

        }

    });

But the above code would work only for Windows and Android devices but not for apple devices on safari. So what could be better code solution that would work on each and every browser as well as on every device.

Here is the solution of your problem. Since All Browsers support Java Script API’s or jQuery therefore this is the best solution to all of your problems.

$(document).ready(function(){ $(document).scroll(function(){ var pos = $(‘body’).scrollTop(); if (document.documentElement.clientHeight + $(document).scrollTop() >= document.body.offsetHeight ) { // ajax call get data from server and append to the div jQuery.ajax({ type: ‘POST’, url: ‘URL’, data: { data_count : data_count }, complete: function( httpResponse, status ) { var response = httpResponse.responseText; var res = jQuery.parseJSON(response); //alert(res); } }); } }); });

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

    $(document).ready(function(){

  $(document).scroll(function(){

      var pos = $(‘body’).scrollTop();

          if (document.documentElement.clientHeight + $(document).scrollTop() >= document.body.offsetHeight )

            {

                // ajax call get data from server and append to the div

                jQuery.ajax({

                type: ‘POST’,

                url: ‘URL’,

                data: { data_count : data_count  },

                complete: function( httpResponse, status )

                {

                    var response = httpResponse.responseText;

                    var res = jQuery.parseJSON(response);

                    //alert(res);

                }

                });

           }

  });

});

428 total views, 2 views today

Share this Onfacebook-8989292twitter-4937983linkedin-7929231google-7141262