Hi I am new to PHP and javascript, am unable to send a variable from Javascript to PHP page. My Javascript code is separate .js file where I have declared a variable count which incremented at each correct answer that user gives. I wanted to pass this data to PHP page so that I can save it to database.
I have tried ajax post method and session storage but nothing seems to be working.
Is the below function correct for post data from JS to PHP?
function score(){
$.post("score_db.php",
{
score:count
},
function(data){
//
});
}
Any help will be appreciated.