--------------------------------------------------------------------------------
Front-end code: <SCRIPT> <br/> var XMLHTTP = false; <br/> try {<br/> XMLHTTP = new activexobject ("msxml2.xmlhttp "); <br/>} catch (e) {<br/> try {<br/> XMLHTTP = new activexobject ("Microsoft. XMLHTTP "); <br/>} catch (E2) {<br/> XMLHTTP = false; <br/>}< br/> If (! XMLHTTP & typeof XMLHttpRequest! = 'Undefined') {<br/> XMLHTTP = new XMLHttpRequest (); <br/>}< br/> function callserver () {<br/> var u_name = document. getelementbyid ("username "). value; <br/> If (u_name = NULL) | (u_name = "") return; <br/> var url = "cu. asp? Name = "+ u_name +" & t = "+ new date (). gettime (); <br/> XMLHTTP. open ("get", URL, true); <br/> XMLHTTP. onreadystatechange = updatepage; <br/> XMLHTTP. send (null); <br/>}< br/> // how can I display the information obtained asynchronously on the current page? <br/> function updatepage () {<br/> If (XMLHTTP. readystate <4) {<br/> test1.innerhtml = "loading... "; <br/>}< br/> If (XMLHTTP. readystate = 4) {<br/> var DATA = XMLHTTP. responsetext; <br/> test1.innerhtml = data; <br/>}< br/> </SCRIPT> <br/> <input type = text id = "username" name = "username" onblur =" callserver () "> <Div id =" test1 "> </div>
Tip: you can modify some code before running
--------------------------------------------------------------------------------
Background code:
<% <Br/> response. charset = "gb2312" <br/> dbpath = "data. mdb "<br/> connstr =" provider = Microsoft. jet. oledb.4.0; Data Source = "& server. mappath (dbpath) <br/> set conn = server. createobject ("ADODB. connection ") <br/> Conn. open connstr <br/> on error resume next <br/> username = trim (request. querystring ("name") <br/> set rs = server. createobject ("ADODB. recordset ") <br/> SQL =" select * from user where u_name = '"& username &"' "<br/> 'response. write SQL <br/> 'response. end () <br/> Rs. open SQL, Conn, 1, 1 <br/> If RS. EOF then <br/> response. write ("can be registered") <br/> else <br/> response. write ("registered") <br/> end if <br/> Rs. close: Set rs = nothing <br/> %>
Tip: you can modify some code before running