XMLHttpRequest mentioned in w3c standards as follows:
If the response contains a header that specifies the character encoding for the response body, this encoding is used. Otherwise, it is assumed that the Unicode UTF-8 is used.
Front-end page sele. asp
<"CODEPAGE =" 936 "%>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Script src = "selectcustomer. js"> </script>
</Head>
<Body>
<Form>
Enter the Project name: <input name = "customers" onkeyup = "showCustomer (this. value)" type = "text"/>
</Form>
<P>
<Div id = "txtHint"> <B> project information is listed here. </B> </div>
</P>
</Body>
</Html>
========================================================== ======================================
Selectcustomer. js page
// JavaScript Document
Var xmlHttp
Function showCustomer (str)
{
XmlHttp = GetXmlHttpObject ();
If (xmlHttp = null)
{
Alert ("your browser does not support AJAX! ");
Return;
}
Var url = "getcustomer. asp ";
Url = url + "? Q = "+ str;
Url = url + "& sid =" + Math. random ();
XmlHttp. onreadystatechange = stateChanged;
XmlHttp. open ("get", url, true );
XmlHttp. send (null );
}
Function stateChanged ()
{
If (xmlHttp. readyState = 4)
{
Document. getElementById ("txtHint"). innerHTML = xmlHttp. responseText;
}
}
Function GetXmlHttpObject ()
{
Var xmlHttp = null;
Try
{
// Firefox, Opera 8.0 +, Safari
XmlHttp = new XMLHttpRequest ();
}
Catch (e)
{
// Internet Explorer
Try
{
XmlHttp = new ActiveXObject ("Msxml2.XMLHTTP ");
}
Catch (e)
{
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
}
Return xmlHttp;
}
========================================================== ====================
Backend getcustomer. asp page
<! -- # Include file = "conn/conn. asp" -->
<%
Response. Charset = "GB2312"
Response. ContentType = "text/html"'The problem can be solved by adding two sentences in red.
Response. expires =-1
StrSQL = "select ProjName from Proj where ProjName like '%" & request. querystring ("q") & "% '"
Response. Write (strsql)
Set RS = Server. CreateObject ("ADODB. RecordSet ")
RS. open strSQL, Conn, 1, 1
Response. write ("<table> ")
While not rs. eof
Response. write ("<tr> <td> ")
Response. write ("<a href = #>" & rs ("ProjName") & "</a> ")
Response. write ("</td> </tr> ")
Response. write ("</table> ")
Response. write ("<table> ")
Rs. MoveNext
Wend
Response. write ("</table> ")
%>