1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function showResult(str)
  5. {
  6. if (str.length==0)
  7. {
  8. document.getElementById("livesearch").innerHTML="";
  9. document.getElementById("livesearch").style.border="0px";
  10. return;
  11. }
  12. if (window.XMLHttpRequest)
  13. {// code for IE7+, Firefox, Chrome, Opera, Safari
  14. xmlhttp=new XMLHttpRequest();
  15. }
  16. else
  17. {// code for IE6, IE5
  18. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  19. }
  20. xmlhttp.onreadystatechange=function()
  21. {
  22. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  23. {
  24. document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
  25. document.getElementById("livesearch").style.border="1px solid #A5ACB2";
  26. }
  27. }
  28. xmlhttp.open("GET","chat.php?q="+str,true);
  29. xmlhttp.send();
  30. }
  31. </script>
  32. </head>
  33. <body>
  34.  
  35. <form>
  36. <input type="button" value="SUBMIT" onclick="showResult("LOL")" />
  37. <div id="livesearch"></div>
  38. </form>
  39.  
  40. </body>
  41. </html>
  42. {
  43.