A newbie writes a game in js, records the players' scores and times, and wants to store them in the database for ranking. How can I safely pass the data to php for storage? A newbie writes a game in js, records the players' scores and times, and wants to store them in the database for ranking. How can I safely pass the data to php for storage?
Reply content:
A newbie writes a game in js, records the players' scores and times, and wants to store them in the database for ranking. How can I safely pass the data to php for storage?
Js regularly executes the request to the server, writes an ajax method, and post the score and time of the player to the server as the parameters of the ajax request for storage.
Ajax + https (for security)
In general, js has two execution environments.
1. In the browser;
2. Like nodejs, it is in a v8 engine.
In the first environment, js and php cannot directly interact with each other. They can only transmit data to php indirectly through ajax.
In the second environment, js and php are both running in their independent interpreters, and they cannot directly interact with each other. However, they can use pipelines, cache and database.
Ajax form submission
$. Ajax ()
A few days ago, I made something similar to real-time chat for my company.
The main program is a. NET-written WCF Service interface that uses POST for data transmission and retrieval.
The front-end page contains the p.
Use js or jquery to refresh the display layer every 5 seconds and refresh the display layer p every time the text is sent.