如何使用jquery实现按需加载 [英] How to implement load on demand using jquery

查看:160
本文介绍了如何使用jquery实现按需加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i在div标签内使用ul,我想按需加载列表,

i表示有滚动在div标签处和div标签内部

ul项目,我不想显示所有项目,因为如果我们显示有大量记录(大约10,000)会降低应用程序的性能所有记录。

如何使用列表项实现按需加载。我想像facebook一样实现这个,当用户滚动内容开始加载时?



注意:我第一次要从服务器加载列表。

Scroll出现在div标签而不是ul标签。

Hi,

i am using ul inside the div tag, i want to load the list on demand,
i mean there is scroll at div tag and inside the div tag there
ul items, i don''t want to show all the items, because there is huge records(approx 10,000) that degrade the performance of application if we show all the records.
How to implement the load on demand with list items. i want to implement this like a facebook, when user scroll the content start loading?

Note: First time i want to load the list from server.
Scroll is appearing in div tag not at ul tag.

推荐答案

我明白了你的期望。

ok,按照你的描述你想要在20个项目结束时会有一个div好吗?然后在20个项目之后会有一个div,其中包含查看更多按钮。当任何人看到更多按钮时,下一个20项将显示,依此类推。对..?



ok,首先你可以计算出你想先显示多少项。您必须在数据库中维护一个索引,该索引是您要获取的循环数据。然后添加查看更多按钮,索引是您选择的循环。当点击查看更多按钮然后将索引发送到数据库并从数据库中获取数据。



就像你必须要做的一样。





谢谢。

Rashed ::孟加拉国。
I got understand your expectation.
ok, as per your description you want that there will be a div at the end of like 20 items ok? then after 20 items there will be a div which will contain "see more" button. When any body click the see more button, the next 20 item will show and so on. right..?

ok, first you can make a calculation that how many items you want to show first. you have to maintain a index in database that which cycle data you are fetching. then add see more button with index that which cycle you are selection. when click the see more button then sent the index to database and get the data from database.

in the same way you have to go ahed.


thanks.
Rashed:: Bangladesh.


上面的答案相当不错。当Scrollbar到达底端时,您也可以执行此操作,只需对服务器进行Ajax调用即可加载其他项。



没有提前的意思,当用户有兴趣看到它们时,你需要自动加载。您可以通过测量滚动条的高度来获得用户的兴趣。
The above answer is fairly good. You can also do that when Scrollbar reach to bottom end, just make a Ajax call to the sever to load other items.

There is no meaning of advance, you will need to load the thing automatically when user is interested to see them. You can get user interest by measuring the height of scrollbar.


这篇关于如何使用jquery实现按需加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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