title: PHP-AJAX call in the same php file-duplicated page
body: <p>when I use the ajax call indicated below, my page is seen 2 times. I think the ajax function calls my page again to view the return result.</p>
  
  <pre><code>&lt;?
  if(isset($_GET['q'])){
  $q=(int)$_GET['q'];
  echo $q;
  }
  ?&gt;
  &lt;html&gt;
   &lt;head&gt;
   &lt;script type="text/javascript"&gt;
   function showUser(str)
   {
   if (str=="")
     {
     document.getElementById("txtHint").innerHTML="";
     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 (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
       {
       document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
       }
     }
   xmlhttp.open("GET","java.php?q="+str,true);
   xmlhttp.send();
   }
   &lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
  &lt;form&gt;
   &lt;select name="users" onchange="showUser(this.value)"&gt;
   &lt;option value=""&gt;Select a person:&lt;/option&gt;
   &lt;option value="1"&gt;Peter Griffin&lt;/option&gt;
   &lt;option value="2"&gt;Lois Griffin&lt;/option&gt;
   &lt;option value="3"&gt;Glenn Quagmire&lt;/option&gt;
   &lt;option value="4"&gt;Joseph Swanson&lt;/option&gt;
   &lt;/select&gt;
   &lt;/form&gt;
   &lt;/br&gt;&lt;div id="txtHint"&gt;&lt;b&gt;Person info will be listed here.&lt;/b&gt;&lt;/div&gt;
  
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>but I only want to use the parameter q in my php mixed html file. for example, with ajax I catch the value of person and put it in q parameter, then use it in an sql query for example(I'll use that query to fill another dropdown list)</p>
  
  <pre><code>"select * from persons where id=".$q; 
  </code></pre>
  
  <p>how can i do that without duplicating the page?</p>
  
  <p>*i cannot put images bc of being rookie</p>