I am totally not sure what you are asking for but here is my guess.
If you want the $result fetched in case 2 from database on your page. Then you can use JSON to pass PHP array to Javascript and then do the rest of the job. Like suppose this is the case no 2 of your switch statement
case "profile_scores":
{
$row = $result->fetch_array(MYSQLI_NUM);
echo json_encode($row);
break;
}
And in your ajax response do this
$.ajax({
type: "POST",
url: "../scripts/getdata.php",
dataType: "html",
data: {id: button_id},
success: function(result){
console.log(result);
console.log(JSON.parse(result));
var phparray = JSON.parse(result);
var correct = phparray[12]; //<---This will return 100
var incorrect = phparray[13]; //<---This will return 10
//I Dont know which one is your correct or incorrect column number but you can have an idea now
}
});
This way you got your PHP array to javascript which was database result. Also I would like to suggest you to correct the Switch syntax. This won't make much difference but should be taken care so this is the correct syntax.
switch($switchcase)
{
case "case1":
{
//Code to go
break;
}
case "case2":
{
//Code to go
break;
}
case "case3":
{
//Code to go
break;
}
}
Note that I have put break; command inside Switch Case