Tekrar selam
Alt kısımda örnek bir kod yazdım. İnceleyerek işe yaradığınız görebilirsiniz.
Sorgunuzu ara.php dosyasında yaparsanız bu şekilde yapabilirsiniz.

index.php
<html>
<head>
<script>
function sonucgoster(str) {
  if (str.length==0) {
    return;
  }
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {  // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (this.readyState==4 && this.status==200) {
      document.getElementById("arama").innerHTML=this.responseText;
      $('#sonuc').html(this.responseText);
    }
  }
  xmlhttp.open("GET","ara.php?q="+str,true);
  xmlhttp.send();
}
</script>
</head>
<body>
<form>
<input type="text" size="30" onkeyup="sonucgoster(this.value)">
<div id="arama"></div>
<div id="sonuc"></div>
</form>
</body>
</html>
Ara.php

<?php if ($_GET["q"]=="1")
{ echo '<h1 style="color:green;">başarılı</h1>'; } 
else { echo '<h1 style="color:red;">hatalı</h1>'; }
?>