title: javascript ajax php display
body: <p>by using javascript ajax i have passed the values to php page...
  display the values after retrieving from database and print in ajax page...it displaying in alert page...but i need to display in ajax page....</p>
  
  <p>ajax coding</p>
  
  <pre><code>&lt;script&gt;
          function optionsAlert()
          {
              alert("call");
              var xmlhttp;
              var qw=document.getElementById('c').value;
              var qw1=document.getElementById('c1').value;
              var qw2=document.getElementById('unit33').value;
              var qw3=document.getElementById('dept').value;
              var qw4=document.getElementById('class').value;
              alert(qw);
              alert(qw1);
              alert(qw2);
              alert(qw3);
              alert(qw4);
  
              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)
               {
                  alert(xmlhttp.responseText);    
  
                  if(xmlhttp.responseText==1){
                  alert("name already Exists" );                  
                  return false;   
                  }        
                 else if(xmlhttp.responseText==0)
                 {
                  alert("name available");
                  document.login.submit();    
                 }
  
              }
           }
  
              var queryString = "?q=" + qw + "&amp;q1=" + qw1 + "&amp;q2=" + qw2 + "&amp;q3=" + qw3 + "&amp;q4=" + qw4;
              xmlhttp.open("get",'ques.php' + queryString,true);
              xmlhttp.send();
          }
  </code></pre>
  
  <p>php page</p>
  
  <pre><code>&lt;?php 
  include('connection.php'); 
  if(($_GET['q']!='') &amp;&amp; ($_GET['q1']!='') &amp;&amp; ($_GET['q2']!='') &amp;&amp; ($_GET['q3']!='') &amp;&amp; ($_GET['q4']!=''))
  {
      $a= mysql_query("select * from unit1 where unit='".$_GET['q']."' and stopic='".$_GET['q1']."' and qtype='".$_GET['q2']."' and dept='".$_GET['q3']."' and class='".$_GET['q4']."'");
      //$a= mysql_query("select * from unit1 where unit='unit1' and stopic='Subtopic1' and qtype='normal questions'");
      if(mysql_num_rows($a)&gt;0)
      {
          while($row=mysql_fetch_array($a))
          {
              $a1=$row['qno'];
              $a2=$row['ques'];
              $a3=$row['ch1'];
              $a4=$row['ch2'];
              $a5=$row['ch3'];
              $a6=$row['ch4'];
              $a7=$row['ans'];
              echo $a1."&lt;br&gt;";echo $a2."&lt;br&gt;";echo $a3."&lt;br&gt;";echo $a4."&lt;br&gt;";echo $a5."&lt;br&gt;";echo $a6."&lt;br&gt;";echo $a7."&lt;br&gt;";
              echo 1;
          }
      }
      else
      {
          echo 0;
      }
  }
  ?&gt;
  </code></pre>