I am coding a ball catching game in JS. At each ball catch I need to update the score of my subject. I think I have to send a request to Ajax to run the code and make the update but it is not clear how to create and send the request and how to handle the request on the Ajaxc side. I would appreciate any help. I put below the a simple part of the code for currently what I am doing which doesnt solve my problem.
<script>
if(ballCatch==true){
$increment=$variableApi->getPE('score')+1;
"<?php $variableApi->setPE('score', $increment);?>"';
}
<script>