Reputation: 9
I'm currently working on a Web Game and I want to store the players points and level into a MySQL database. The points are constantly going up so having it autosave using POST and GET will cause the page to refresh and points will be lost ( I think ? )
Upvotes: 1
Views: 349
Reputation: 177
Bind ajax call on event like change of text value: For example:
<input type="text" name="id" id="btn" onchange="ajaxfunction()"/
<script>
function ajaxfunction()
{
enter ajax code here
}
</script>
Upvotes: 1
Reputation: 1291
Still can't comment, anyways AJAX is outdated. Check out the new fetch method or web workers.
http://www.html5rocks.com/en/tutorials/websockets/basics/
Or just avoid the server and use Web SQL (this will disable things like top player score, top players, basically anything that is not related to streaming multi-player gaming)
http://www.tutorialspoint.com/html5/html5_web_sql.htm
Google HTML5 and JavaScript gaming tutorial.
Upvotes: 1