locked
JQuery scroll paging does not work on mobile RRS feed

  • Question

  • User1506863308 posted

    On mobile devices, the same products displayed and for example there are 15 products in database but 20 products displayed when i scroll down. But its working correctly on computer.

    var pageNumber = 1;
    var pagePost = true;
    $(window).scroll(function () {
                   if (pagePost) {
                    if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
                        $.ajax({
                            url: '/product/list',
                            data: { "pageNumber": pageNumber},
                            success: function (data) {
                                if ($.trim(data) == '' || data == null || data.result == "0") {
                                    pagePost = false;
                                    return;
                                }
                                else {
                                    $("#productList").append(data);
                                    pageNumber++;
                               }
    
                            }
                        });
                    }
                }
            });
    Sunday, December 20, 2020 4:03 PM

All replies

  • User-939850651 posted

    Hi ModeXL,

    On mobile devices, the same products displayed and for example there are 15 products in database but 20 products displayed when i scroll down. But its working correctly on computer.

    Based on the data you provided, I tried to reproduce the problem, but I don’t know other related codes or database query statements, so I’m not sure if it will affect the results.

    And I found that the scroll events are different in these two devices, the mobile device is touchmove event, and the computer is scroll event.

    For more details, please refer to this case below:

    https://stackoverflow.com/questions/44744586/scroll-event-not-working-on-mobile

    Best regards,

    Xudong Peng

    Monday, December 21, 2020 5:34 AM