Asynchronous Transfer GET

Syntactically, an asynchronous transfer may look more complex to the coder. However, it allows the webpage to be responsive. For example, with it, you can display an animated gif while some data is being retrieved.
This PHP script searches as you type. Because the "GET" method is used, the results may be cached. A random parameter is passed using Math.random() to ensure that the latest version of "gethint.php" is used.
RESETRUNFULL
<?php
$a = ["Paul","Crowe","Betrand","Mary","Irene","Fiona","Gundesen","Hegel","Singa","Johan","Katherine","Jacky", "Lina","Opheus","Petronas","Ananda","Racheal","Cindy","Doris","Eva","Livita","Sunny","Trovalta","Inu","Purple","Liza","Alexander","Ellen","Wendy","Vincent"];
 $q=$_GET["q"];
 if (strlen($q) > 0){
    $hint="";
    for($i=0; $i<count($a); $i++){
       if (stripos($a[$i],$q)) {
          $hint=($hint=="")?$a[$i]:$hint." , ".$a[$i];
       }
    }
 }

 echo ($hint=="")?"no suggestion":$hint;
 ?>

<!DOCTYPE html><html><head>
<script>
function showHint(s){
   var xhr;
   if (s.length==0){
      document.getElementById("hints").innerHTML="";
      return;
   }
   xhr=new XMLHttpRequest();
   xhr.onreadystatechange=function() {
      if (xhr.readyState==4 && xhr.status==200)           
         document.getElementById("hints").innerHTML=xhr.responseText;
   }
   xhr.open("GET","gethint.php?q="+s+"&r="+Math.random(),true); 
   xhr.send();
}
</script>
</head><body>
   <h3>Start typing a name:</h3>
   Name: 
   <input type="text" onkeyup="showHint(this.value)" />
   <p>Suggestions: <span id="hints"></span></p>
</body></html>