سؤال

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

هل كانت مفيدة؟

المحلول

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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top