* I want to put together an experience system for a game. The idea itself is that within this function:
function Experiencia(...parámetros para definir la exp final){
return expC = 50;
}
... a process is armed depending on what was fought, how much experience is returned.
* Now to be able to update the experience that the player already had, I need to obtain that variable value and send it via AJAX to a file "ActualizaStat.php" so that I can make an UPDATE in the MYSQL database.
<button id="btnInfComb"> <a href="enviaDatosCombate.php">Aceptar</a></button>
function EnviaDatosCombate() {
var xhr = new XMLHttpRequest()
xhr.open("POST","ActualizaStat.php",true)
xhr.onreadystatechange = function () {
if(xhr.readyState == 4 && xhr.status == 200){
var a = Experiencia()
//Aca dentro que tendria que hacer para poder mandar el valor en
//SEND
}
}
xhr.send(a)
}
* On the PHP side of "ActualizaStat.php" I would have the following piece of code. (It is not necessary to tell me how to perform the update, I only show this fragment to know that I call it through POST ..)
<?php
$datos = $_POST['a'];
echo $datos;
?>
I would greatly appreciate the help as always.