|
查看: 700|回复: 1
|
請幫我看一下,ajax+php的用戶名驗證代碼
[复制链接]
|
|
|
- 1. var xmlHttp;
- 2. function createXMLHttpRequest()
- 3. {
- 4. if(window.XMLHttpRequest)
- 5. {
- 6. xmlHttp = new XMLHttpRequest();//mozilla
- 7. }
- 8. else if(window.ActiveXObject)
- 9. {
- 10. try
- 11. {
- 12. xmlHttp = new ActiveX0bject("Msxml2.XMLHTTP";//IE5
- 13. }
- 14. catch(e)
- 15. {}
- 16. try
- 17. {
- 18. xmlHttp = new ActiveXObject("Microsoft.XMLHTTP";//IE6
- 19. }
- 20. catch(e)
- 21. {}
- 22. if(!xmlHttp)
- 23. {
- 24. window.alert("error";
- 25. return false;
- 26. }
- 27. }
- 28. }
- 29.
- 30.
- 31. function startRequest(username)
- 32. {
- 33.
- 34. createXMLHttpRequest();
- 35.
- 36. xmlHttp.open("GET","ckuser.php?name="+username,true);
- 37. xmlHttp.onreadystatechange = handleStateChange;
- 38. xmlHttp.send(null);
- 39. }
- 40.
- 41.
- 42. function handleStateChange()
- 43. {
- 44. if(xmlHttp.readyState==4)
- 45. {
- 46. if(xmlHttp.status==200)
- 47. {
- 48.
- 49. if(xmlHttp.responseText == true){
- 50.
- 51. document.getElementById("ckuser".innerHTML = 'this user name already been use';
- 52. }
- 53. else if(xmlHttp.responseText == false)
- 54. {
- 55.
- 56. document.getElementById("ckuser".innerHTML = 'you can use this user name';
- 57. }
- 58. }
- 59. }
- 60. }
复制代码 這是我從網上抄下來的,31到39行那一段function我不明白什么意思,我還是php新手,我覺得跟php有關系,請高手解釋一下,謝謝
[ 本帖最后由 y小叶y 于 4-10-2008 10:36 AM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 5-10-2008 10:32 PM
|
显示全部楼层
那是一个link来得
是用来read你给她的value用的 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|