PHP + Ajax username detection details

Source: Internet
Author: User

In this example, three files are required: Ajax. jsvar xmlHttp; // function S_xmlhttprequest () {if (window. activeXObject) {xmlHttp = new ActiveXObject ('Microsoft. XMLHTTP ');} else if (window. XMLHttpRequest) {xmlHttp = new XMLHttpRequest () ;}} function funphp100 (name) {// get form Content // http://www.ruoshuiyx.com Shenyang site construction var f = document. myform. user. value; // reference the instantiation process S_xmlhttprequest (); // open the request xmlHttp. open ("GET", "index. php? Id = "+ f, true); // you are ready to execute xmlHttp. onreadystatechange = byphp; xmlHttp. send (null);} function byphp () {if (xmlHttp. readyState = 1) {document. getElementById ('php100 '). innerHTML = " </script> <formname =" myform "action =" "method =" post "enctype =" type/plain "> username // http://www.ruoshuiyx.com Shenyang website construction: <inputtype = "text" name = "user" value = "" onblur = "funphp100 ('php100 ') "> <divid =" php100 "> </div> </form> Index. php <? Phpif ($ id = $ _ REQUEST [id]) {// for ($ I = 1; $ I <3; $ I ++) /// {// echo $ id; // sleep (1); //} sleep (2); if ($ id = '20140901 ') {echo "already exists";} else {echo "can be registered";} // exit () ;}?> Knowledge Point: 1. Ajax technology implements the user name check Principle 2. Learning HTML to trigger several onblur events will occur when the object loses focus. The onchange event occurs when the domain content changes. The onclick event occurs when the object is clicked. The onfocus event occurs when the object obtains the focus. The onkeydown event occurs when you press a keyboard button. The onkeypress event occurs when the keyboard key is pressed and a key is released. The onkeyup event occurs when the keyboard button is released. The onmousedown event occurs when the mouse is pressed. The onmousemove event occurs when the mouse pointer moves. The onmouseout event occurs when the mouse pointer is removed from the specified object. The onmouseup event occurs when the mouse button is released. 3. How to obtain the data content in the form <formname = "myform "... <Inputname = user type = text value = ""> </form> document. myform. user. value

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.