Answer the question
In order to leave comments, you need to log in
How to implement a random issue service?
Good afternoon friends.
I think everyone knows such a site as Kinopoisk. They have a "Random Movie" section (kinopoisk.ru/chance) Can someone suggest how this service is implemented? Maybe there are links with information on similar services. And then I don’t really know how to even ask a question in a search engine.
Thank you.
Answer the question
In order to leave comments, you need to log in
To understand how it works, look at AJAX requests that load random movies:
All parameters are passed in the request, depending on the filters you have chosen, in response comes an array of 5 random movies that fit the specified parameters:
On the server, for sure, a list of random movies is selected by a simple query to the database using the RAND function.
It is worth noting that the request is made 5 films ahead in order to show the user without delay, i.e. when he clicks the "random movie" button, the movies are shown to him in order from the previous ajax request, and the new request has already selected the next 5 new movies and they are in memory on the client (in a JavaScript variable), as soon as the user has passed 5 movies, there is a new request to the server, and the user is shown films downloaded earlier by the previous request.
For a visual "WOW effect" you can use some kind of JS plugin, content slider like www.menucool.com/responsive-slider. Or you can write the slide transition animation yourself using css transition.
You need a simple random number generator. The meaning is this.
There is an array with data, from 1 to 1000 for example. run a random number generator from 1 to 1000, and the given number will be the array element. And everything else is just additional checks that narrow the array.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question