Turntable raffle. When you click the lucky draw button, you want to trigger the rotation when the data does not come, and specify the appropriate location when you get the data.

when making a turntable raffle, send ajax, when clicking the raffle button. If the server delay is relatively large and the requested data cannot be returned in time, then it will appear that it cannot be rotated after clicking the raffle button, so what method can be done after clicking the button, before getting the data, the turntable starts to rotate, and so on, after getting the data, stop at the corresponding position according to the acquired data. Thank you, bosses


my idea is to start turning when I click, and keep turning when there is no data to return. When the data is returned, I execute the following logic: just stop at the specified position after 5 laps and 10 laps.


if the requested data cannot be returned in time when the server delay is large, it will appear that it cannot be rotated after clicking the lucky draw button

Why can't you turn? Isn't ajax asynchronous?

...//
$.ajax(...,success:()=>{
    ...
    ...//
})

do you click rotate to determine whether you have requested the data back or not? In that case, can you consider writing a method that can also turn when there is no data (such as creating some fake data)? after the data request comes back, you will still drop the previous method.


first of all, when you write about the rotation of the turntable, you should consider its stop and where it stops.
then, during the time you click start-get data, use the timer to let it spin itself.
finally, after getting the data, set the stop position and then let it turn a few more times so that it can stop at the specified position (in case the result data has been transferred).

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44e17-44aee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44e17-44aee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?