jQuery 或 db 函数一次将一组数据库记录加载到一个轮播中?
我希望这不会太复杂。
我正在尝试帮助某人使用 jQuery 轮播类型滑块(希望平滑 Div 滚动: http://www.smoothdivscroll.com /)显示数据库中的产品。不幸的是,他们正在使用一个名为 4D 的平台,并且他们想要自己完成所有数据库脚本。将会有数百到数千种产品(每种产品有一张缩略图)。他们希望在轮播中一次只加载 60 个左右,这样就不会因为一次加载所有内容而使网站陷入困境。
我无法控制服务器端脚本,无法控制他们选择显示多少产品。我基本上是在为它们组合一个 HTML/jQuery/CSS 模板。我只是想思考如何向他们解释这一点。我想确保我是对的,因为我不是 jQuery 专家。
他们说从数据库中提取的记录数是前端 jQuery 函数,而我说 jQuery 只是显示数据库查询提供的内容。由他们选择要提供多少总记录。我是不是偏离了基地?有没有办法让我(jQuery)一次只加载(加载,不显示)60 条记录,直到用户滚动到足够远需要更多,然后从查询结果中获取更多记录?或者他们是否必须对 60 条记录的每个部分进行数据库查询(可能基于 jQuery 中的挂钩,告诉他们是时候查询下一组记录了)?当然,当用户到达轮播末端时,所有内容都会被加载......是吗?
我确信这将是两者的结合,但他们试图让这一切都由我来做(jQuery)...我只需要一些确认,证明我的思路正在朝着正确的方向发展。
想法?
谢谢你! 艾莉森
I hope this isn't too convoluted.
I'm attempting to help someone use a jQuery carousel type slider (hopefully Smooth Div Scroll: http://www.smoothdivscroll.com/) to display products from a database. Unfortunately, they are using a platform called 4D, and they want to do all of their own db scripting. There are going to be hundreds to thousands of products (with 1 thumbnail photo each). They would like to only load 60 or so at a time in the carousel so to not bog down the site with EVERYTHING being loaded at once.
I have no control over the server side script, no control over how many products they are choosing to display. I'm basically putting together an HTML/jQuery/CSS template for them. I'm just trying to wrap my brain around how to explain this to them. And I want to make sure I am right, since i am not a jQuery expert.
They are saying that the number of records pulled from the database is a front end jQuery function, whereas I say that the jQuery just displays what the database query serves up. It is up to them to choose how many total records to serve. Am I off base there? Is there a way for me (the jQuery) to say only load (load, not display) 60 records at a time until the user scrolls far enough to need more, then get more from the query results? Or do they have to do a db query for each section of 60 records (perhaps based on a hook in the jQuery telling them it is time to query the next set)? Of course, by the time the user gets to the end of the carousel, everything will be loaded anyway... yea?
I'm sure it's going to be a combination of the two but they are trying to make it all me (jQuery)... I just need some confirmation that my line of thinking is going in the right direction.
Thoughts?
Thank you!
alison
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
4D 确实有一个 SQL 接口,并且 SQL 绝对允许您将选择查询的返回限制为您选择的任意数量的结果。
更多信息请参见:http://www.4d.com/docs/CMU/CMU18425.HTM
有两种方法可以做到这一点:
(1) 服务器将结果数作为参数,您必须在前端指定。 4D 绝对有能力做到这一点,因为它有 SQL 命令引擎。他们的服务器脚本是否具有利用此功能的函数?我不能说。也许这样的函数已经存在于他们的 PHP 或他们使用的任何脚本中,只是我们还不知道而已。
(2)只需查询整个数据库即可获得整个数据集。我的偏好是将其作为 JSON 对象获取。然后你可以使用 javascript 来限制显示的响应。我通常更喜欢这种方法,因为它对客户端来说更流畅,但如果您尝试发送巨大的数据集,问题是加载时间。如果您选择此方法,则可以移动缩略图的所有 URL,然后稍后异步加载它们。这仍然全部在前端,服务器只有一个“getall”类型的函数(它返回一个巨大的 json 文本,通常没有那么大而无法移动)。
4D does have an SQL interface, and SQL definitely lets you limit the return of the selection query to whatever number of results you choose.
more here:http://www.4d.com/docs/CMU/CMU18425.HTM
There are two ways you can do it:
(1) the server takes the number of results as a parameter, which you must specify on the front end. 4D is definitely capable of this, given that it has SQL command engine. Does their server script have a function that utilises this capability? I can't say. Maybe such a function already exists in their PHP or whatever script they use, and we just don't know about it yet.
(2) you can just query the entire database and get the entire dataset. My preference is to get it as a JSON object. Then you can use javascript to limit the displayed responses. I usually prefer this method as it is smoother for the client, but the issue is loading time if you are trying to send an enormous dataset. If you choose this method, you can move all the URL's for the thumbnails, then load them asynchronously later on. This is still all in the front end, and the server just has a "getall" kind of function (which returns a giant json of text, usually not that large to move).