title: Fetch value of one text box and print to a div name "output" with a click of button with ajax
body: <pre><code>&lt;script type="text/javascript"&gt;
  document.getElementById('s1').onclick=function()
  {
  var value1 = document.getElementById('input').value;
  var aj;
  if(window.ActiveXObject)
  {
      aj=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if(window.XMLHttpRequest)
  {
      aj=new XMLHttpRequest();
  }
  aj.onreadystatechange=function()
  {
      if(aj.readyState==4 &amp;&amp; aj.status==200)
      {
  
          document.getElementById("output").innerHTML=aj.responseText;
      }
  }
  aj.open("GET","tstprinajax.php?name="+value1,true);
  aj.send();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>This is not working for me. I want to fetch value of one text box and print to a div name "output" with a click of button with AJAX.</p>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;body&gt;
  &lt;form action=""&gt;
  &lt;input type="text" id="input" /&gt;
  &lt;button id="s1"&gt;&lt;/button&gt;
  &lt;div id="output"&gt;&lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>tstprinajax.php:</p>
  
  <pre><code>&lt;?php
  $q = $_GET["name"];
  print "&lt;font size='+6' color='#FF0000'&gt;$q&lt;/font&gt;";
  ?&gt;
  </code></pre>