Ajax displays real-time registration user detection problems ..

Source: Internet
Author: User
--------------------------------------------------------------------------------
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.