Slide show advise needed
i have 1500 images in a ftp folder.
image names are like :
Now i need to randomly load theis images in to the slide show which is written in basic JS.
plse tell me how to do this.
the slide show can be paused and resume at any time.
Use a server-side script to dump an array of those names into the page.
my plan is like this,
in db the data are as flollws for each image,
ID | picpath | description | date_capture
Now my plane is to generate a randam no and load the picture and detals using php & ajax for each image. so for each image, an ajax xmlhttprequest is made. is this ok?
Yikes - do NOT DUMP THOSE ARRAYS to your page with a server side script... that is sheer nonsense. You will create a nice bloated page. If you must leave the names the same on the server - then at least put an array in a separate .js file - and set chaching so it is downloaded once (if you need version control use the folder).
A better solution is to RENAME the images on the server - im0, im2, im3, im4. If they are different file types then at most you can store or deliver a compact array with the file types only - and the rest of the file name can be automatically constructed by JS on your page...
Your number of requests should not be a big deal via AJAX - provided your slide show is operating at a reasonable speed. The issue will be having a reasonably fast loading page - which is why i recommend changing the file names if you can.
An alternative is to have the client be unaware of the file names at all. You will need to maintain some sort of a LIFO buffer or similar structure on the server with the images - keep track of ther order handed out (use a cursor or other variable in your HTTP request) - and then simply have the client make a request like "get next 10 images" or next 5 or whatever you want... whenever the slideShow gets within a range of the end of the images fetched in the last request.
In that case your client does not even need to know the file names it is requesting. Just return a JSON array of URLs to the images from the server.
Thanks kceleb9 for the explanation. any problem ill come back.
I agree, that's a much better technique.