Ajax GET and POST method

Ajax GET and POST method

I am currently using ajax GET method to pass my value into the same page.
I look at the console.log, the requestURL is able to pass the value like www.example.com/test?q=1. 
unfortunately,when it request by the server site, the get value is not assigned to the variable $_GET['q']; As a result, i couldn't manipulate the value after the request. 

Do you have any idea what've I missed ? or it is fundamentally not allow to do in the same page.

$anyvar = $_GET['q'];
  1. function showData(str)
  2. {
  3.   bool = false;
  4.   var str1 = "";
  5.   if(str == "")
  6.   {
  7.     document.getElementById("select_field").innerHTML = "";
  8.     return;
  9.   }
  10.   else
  11.   {
  12.     
  13.     if(window.XMLHttpRequest)
  14.     {
  15.       xmlhttp = new XMLHttpRequest();
  16.       console.log(xmlhttp);
  17.     }
  18.     else
  19.     {
  20.       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  21.       console.log(xmlhttp);
  22.     }
  23.     xmlhttp.onreadystatechange = function()
  24.     {
  25.       if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
  26.       {
  27.         document.getElementById("select_field").innerHTML=document.getElementById("selection").innerHTML;
  28.       }
  29.     };
  30.     
  31.   }
  32.   xmlhttp.open("GET", "reports.php?q=" + str, true);
  33.   xmlhttp.send();
  34. }