Example of partial refresh registration verification for phpajax

Source: Internet
Author: User
Example of partial refresh registration verification for phpajax

  1. // JavaScript Document

  2. Var xmlHttp;
  3. Function S_xmlhttprequest ()
  4. {
  5. XmlHttp = null;
  6. If (window. XMLHttpRequest)
  7. {// Code for IE7, Firefox, Opera, etc.
  8. XmlHttp = new XMLHttpRequest ();
  9. }
  10. Else if (window. ActiveXObject)
  11. {// Code for IE6, IE5
  12. XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
  13. }
  14. }

  15. Function getName (name)

  16. {

  17. If (name = document. myform. name. value)

  18. {
  19. S_xmlhttprequest ();
  20. XmlHttp. open ("get", "data. php? Name = "+ name, true );
  21. XmlHttp. onreadystatechange = byname;
  22. XmlHttp. send (null );
  23. }

  24. }

  25. Function byname ()

  26. {
  27. If (xmlHttp. readyState = 1)
  28. {
  29. Document. getElementById ('name'). innerHTML = "loading ....";
  30. }
  31. If (xmlHttp. readyState = 4)
  32. {
  33. If (xmlHttp. status = 200)
  34. {
  35. Var name = xmlHttp. responseText;
  36. Document. getElementById ('name'). innerHTML = name;
  37. }
  38. }
  39. }
  40. Function getEmail (email)
  41. {
  42. Var email = document. myform. email. value;
  43. If (email = "")
  44. {
  45. Alert ("user name cannot be blank ");
  46. Document. myform. email. focus ();
  47. Return false;
  48. }
  49. Else
  50. {
  51. S_xmlhttprequest ();
  52. XmlHttp. open ("get", "data. php? Email = "+ email, true );
  53. XmlHttp. onreadystatechange = byemail;
  54. XmlHttp. send (null );
  55. }

  56. }

  57. Function byemail ()
  58. {
  59. If (xmlHttp. readyState = 1)
  60. {
  61. Document. getElementById ('email '). innerHTML = "loading ....";
  62. }
  63. If (xmlHttp. readyState = 4)
  64. {
  65. If (xmlHttp. status = 200)
  66. {
  67. Var email = xmlHttp. responseText;
  68. Document. getElementById ('email '). innerHTML = email;
  69. }
  70. }
  71. }

2. register. php file

  1. Register page_bbs.it-home.org

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.