如何在页面中滚动200px时检索前2个记录数据,在jquary中滚动400px时,请回溯200记录第二个? [英] How to retrieve first 2 record data when scroll 200px in page , retrive 200record second when scroll 400px in jquary?

查看:133
本文介绍了如何在页面中滚动200px时检索前2个记录数据,在jquary中滚动400px时,请回溯200记录第二个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在页面中滚动200px时检索前2条记录。之后滚动400px时,检索数据库中的第二个2记录





我尝试过:



i我尝试了一些代码但它无法正常工作任何人都能给我这个问题的解决方案

解决方案

考虑使用其中一个无限滚动jQuery库并根据需要提取数据。而不是自己编写代码,该库可以处理滚动等。最常见的是事件被触发 - 计算机在计算中是准确的,用户可能以不同的速度滚动。这些库可以根据需要顺序提取数据。



其中一个库:无限滚动 [


1.使用分页(OFFSET / FETCH)从DB获取记录

示例:
使用OFFSET / FETCH进行分页:更好的方法 [ ^ ]



2.使用检查当前位置window.scroll()方法

 


(窗口).scroll(function(){
if(


i want to retrieve first 2 record when scroll 200px in page . after that when scroll 400px ,retrieve second 2 record in database



What I have tried:

i am tried some code but it dose not work correctly can anyone give me solution for this problem

解决方案

Consider using one of the infinite scroll jQuery libraries and pull the data as needed. Instead of writing the code yourself, that library can handle the scrolls and so on. Mostly what happens is that events are triggered — computers are accurate in calculations, and users might scroll at different speeds. These libraries can help in pulling data sequentially as needed.

One of such libraries: Infinite Scroll[^]


Let's break down your problem first.

1. Use paging (OFFSET/FETCH) to fetch records from DB
Example: Pagination with OFFSET / FETCH : A better way[^]

2. Check your current position with window.scroll() method


(window).scroll(function() { if(


这篇关于如何在页面中滚动200px时检索前2个记录数据,在jquary中滚动400px时,请回溯200记录第二个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆