<script type="text/javascript">
document.getElementById("txtHint").innerHTML="";
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
if (xmlhttp.readyState==4 && xmlhttp.status==200)
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
xmlhttp.open("GET","/example/aspnet/gethint.aspx?q="+str,true);
<h3>请在下面的输入框中键入字母(A - Z):</h3>
姓氏:<input type="text" id="txt1" onkeyup="showHint(this.value)" />
<p>建议:<span id="txtHint"></span></p>