jQuery-SlotMachine
jQuery-SlotMachine copied to clipboard
Slot machine with Ajax
Hello i wana use tricky slot machine with ajax , to choose the numbers to display the result from a database, any ideas?
Sorry for the late reply.
Anyways, I implemented this feature yesterday. (Laravel). It is not really hard.
Here is how you can do it (VERY BASIC):
-
Create a random number generator function in PHP (With probability stuff etc) and return the generated number. You can also return a specific value from your database.
-
Send an AJAX request to the PHP file / route that includes the generator function and store the response text in a variable. (On button click for example).
-
On AJAX success run the slot machine. Make sure to add the following content to your slot machine before doing so:
randomize() { return YOURVAR; }
- You are done. Please also be aware of the fact that the images of your slot machine div start at number 0. Number 0 would be picture 1 and so on.
Good Luck.