AJAX.JS
上传用户:szhf331
上传日期:2022-06-22
资源大小:1032k
文件大小:3k
源码类别:

行业应用

开发平台:

JavaScript

  1. function checkcode(regcode){
  2. var xmlhttp;
  3. try{
  4. xmlhttp=new XMLHttpRequest();
  5. }
  6. catch(e){
  7. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  8. }
  9. xmlhttp.onreadystatechange=function(){
  10. if (xmlhttp.readyState==4){
  11. if (xmlhttp.status==200){
  12. var data=xmlhttp.responseText;
  13. code_result(data);
  14. }
  15. else{
  16. $("span")[13].innerHTML="验证码校验失败,请联系管理员";
  17. }
  18. }
  19. else{
  20. $("span")[13].innerHTML="正在进行验证码校验...";
  21. }
  22. }
  23. //alert("请详细填写家庭住址!");
  24. xmlhttp.open("post", "check_code.asp", true);
  25. xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  26. xmlhttp.send("regcode="+escape(regcode));
  27. }
  28. function code_result(data){
  29. var resultbox=$("span")[13];
  30. if(data==1){
  31. resultbox.innerHTML='<img src="images/reg_yesok.gif"/> 验证码正确';
  32. flag[5]=1;
  33. check_data();
  34. }
  35. else{
  36. resultbox.innerHTML='<img src="images/reg_yesno.gif"/> 验证码错误';
  37. flag[5]=0;
  38. check_data();
  39. }
  40. }
  41. //--------------------------------------------------------------------
  42. function checkid(regid){
  43. var xmlhttp;
  44. try{
  45. xmlhttp=new XMLHttpRequest();
  46. }
  47. catch(e){
  48. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  49. }
  50. xmlhttp.onreadystatechange=function(){
  51. if (xmlhttp.readyState==4){
  52. if (xmlhttp.status==200){
  53. var data=xmlhttp.responseText;
  54. id_result(data);
  55. }
  56. else{
  57. $("span")[0].innerHTML="用户名检测失败,请联系管理员";
  58. }
  59. }
  60. else{
  61. $("span")[0].innerHTML="正在进行用户名校验...";
  62. }
  63. }
  64. xmlhttp.open("post", "reg_check.asp", true);
  65. xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  66. xmlhttp.send("regid="+escape(regid));
  67. }
  68. function id_result(data){
  69. var resultbox=$("span")[0];
  70. if(data==1){
  71. resultbox.innerHTML='<img src="images/reg_yesok.gif"/> 用户名可用';
  72. flag[4]=1;
  73. check_data();
  74. }
  75. else{
  76. resultbox.innerHTML='<img src="images/reg_yesno.gif"/> 该用户名已经被注册';
  77. flag[4]=0;
  78. check_data();
  79. }
  80. }
  81. //--------------------------------------------------------------------
  82. function sendinfo(regname,pwd,email,problem,Answer,UserName,Age,IdentityNO,Phone,Telephone,address,Sex){
  83. var xmlhttp;
  84. try{
  85. xmlhttp=new XMLHttpRequest();
  86. }
  87. catch(e){
  88. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  89. }
  90. xmlhttp.onreadystatechange=function(){
  91. if (xmlhttp.readyState==4){
  92. if (xmlhttp.status==200){
  93. var data=xmlhttp.responseText;
  94. reg_result(data);
  95. }
  96. else{
  97. $("span")[14].innerHTML="注册失败,请联系管理员";
  98. }
  99. }
  100. else{
  101. $("span")[14].innerHTML="正在进行用户名注册...";
  102. }
  103. }
  104. xmlhttp.open("post", "reg.asp", true);
  105. xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  106. xmlhttp.send("regname="+escape(regname)+"&pwd="+escape(pwd)+"&email="+escape(email)+"&problem="+escape(problem)+"&Answer="+escape(Answer)+"&UserName="+escape(UserName)+"&Age="+escape(Age)+"&IdentityNO="+escape(IdentityNO)+"&Phone="+escape(Phone)+"&Telephone="+escape(Telephone)+"&address="+escape(address)+"&Sex="+escape(Sex));
  107. }
  108. function reg_result(data){
  109. if(data==1){
  110. //$("span")[14].innerHTML='<a href="login.asp" target="_blank">'+$("input")[0].value+",注册成功!</a>";
  111. srcs.src=srcs.src+'?'+Math.random();
  112. top.location.href='Registration.asp?action=suc';
  113. }
  114. else{
  115. $("span")[14].innerHTML="注册失败,请联系管理员";
  116. }
  117. }