this is how am using the ajax
$.get('checkanswer.php',{'clickedvalue':clickedvalue,'qid':qid},function(data){
$this.find(".report").html(data);
and this is my PHP code from where data is coming
<?php
$countresult=0;
$questionid=$_GET['qid'];
$answer=$_GET['clickedvalue'];
$dbconnect=mysqli_connect('localhost','root','','quiz')or die("Error Connecting to database");
$query="select answer from question_answer where id=$questionid";
$result=mysqli_query($dbconnect,$query);
while($rows=mysqli_fetch_array($result))
{
$dbanswer=$rows['answer'];
}
if($dbanswer==$answer)
{
echo "Correct";
$countresult=$countresult+1;
}
else{
echo "Incorrect";
$countresult=$countresult-1;
}
?>
Now previously i was just checking the result is correct or not and displaying tha result but now i want the PHP page to return even the variable that store the counts that is stored in $countresult. I know I have to use json but how to use it in PHP page ,pass the value and get access to that value from another page ,