php - How to Update a Database while typing without leaving a page? -


I know there are many other questions about this topic but unfortunately (my knowledge is very low in AJAX and PHP ) I did not get it to work, so please forgive me if this question is redundant or has already been done, but I need some more "authentic" explanation to better understand this issue.

Here's the topic:


  • I have a game where all the players have been hosted on the site of their character sheets.
  • Character Sheet has many & lt; Input & gt; Tags and players are created by just fill them out So, for example, my strong points are inside an input and so on.
  • I am collecting all this data from inside a database
  • What I've learned so far is that I only have to "save" data through "post" And I can refresh the page.

My question Is it possible to "update" the database when a input to whith "OnBlur")


So for example I have an example input:

   

Maybe you need a player ID or a hidden area on the page, perhaps?

Then call AJAX

  $ (". I50xauto"). Blur (function () {$ .ajax ({url: 'path / to / saveToDB.php', type: ' Post ', data: {player_id: $ ("# Player_id"). Val (), spell_school: $ (this) .val ()}};});  

Then the PHP file Inside (lets call it SaveToDB.php), you can easily You can update the database in the form, access the passed passes through the pass variable:

  $ _ POST ['spell_school'] $ _POST ['player_id'] < / Code> 

Comments