This article mainly shares with you an example of the tradition of ajax implementation of user name verification and the $.post method of jquery. It has a good reference value and hopes to help everyone fully master ajax.
The first type: traditional ajax asynchronous request, the background code and effects are at the bottom
First we create a registration page in eclipse regist.jsp, create a form form. Note that since we are only implementing the effect of user name verification, the red departments below are the objects we need to study, so other departments can be ignored.
The content is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
The second way: use ajax in jQuery achieve the above effects. First of all, the form and Action remain unchanged, we only need to change the script.
Step one: Introduce js file
Step 2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Then let’s take a look at how the background data will be returned. Since I am implementing this using the ssh framework, for the sake of convenience, I only show how to return data in the Action. Regarding the implementation of the service layer and dao layer in the ssh framework, please solve it yourself.
##
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
The effect is as follows:
The specific implementation of JQuery user name verification_jquery
Perfect Implementation of ID card verification js regular method
JavaScript tutorial registration page form verification
The above is the detailed content of Examples to explain the tradition of ajax user name verification and jquery's $.post method. For more information, please follow other related articles on the PHP Chinese website!