I'm trying to update a database value each time complete() occurs. The following code is located in a file called 'user.php' and $u is globally defined elsewhere in the file. The value pT simply doesn't update when complete() is ran. Thanks in advance.
<?php
if (isset($_POST['pT'])){
$pT = $_POST['pT'];
$sql = "UPDATE progress SET progressbar='$pT' WHERE username='$u'";
$query = mysqli_query($conn, $sql);
exit();
}
?>
var pT = 0;
function complete(){
pT = pT + 25;
$.ajax({
url: 'user.php',
type: 'POST',
data: {'pT': pT},
success: function() {}
});
}