Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <div id="container">
  2. <header>
  3. <h1>Registration Form</h1>
  4. <hr>
  5. </header>
  6. <article>
  7. <form action="completed.html" method="POST" accept-charset="ISO-8859-1">
  8. <label for="FirstName"><b>First Name:</b></label>
  9. <input id="FirstName" type="text" placeholder="John" required>
  10. <label for="LastName"><b>Last Name:</b></label>
  11. <input id="LastName" type="text" placeholder="Doe" required>
  12. <label for="email"><b>Email:</b></label>
  13. <input id="email" type="text" placeholder="example@mail.com" required>
  14. <label for="password"><b>Password:</b></label>
  15. <input id="password" type="password" placeholder="Password here." required>
  16. <p></p>
  17. <button id="addUser">Submit</button>
  18. </form>
  19. </article>
  20. <footer>
  21. Copyright @ 2017
  22. </footer>
  23. </div>
  24.  
  25. $(function() {
  26.  
  27. var $firstName = $("#FirstName");
  28. var $lastName = $("#LastName");
  29. var $email = $("#email");
  30. var $password = $("#password");
  31.  
  32. var $data = $("#data");
  33.  
  34. $.ajax({
  35. type: "GET",
  36. url: "http://rest.learncode.academy/api/register/user",
  37. success: function(users) {
  38. $.each(users, function(i, user) {
  39. addUser(user);
  40. });
  41. },
  42. error: function() {
  43. alert("error loading user");
  44. }
  45. });
  46.  
  47. function addUser() {
  48. $data.append(user.firstName + user.lastName + user.email + user.password);
  49. }
  50.  
  51. $("#addUser").on("click", function() {
  52.  
  53. var user = {
  54. firstName: $firstName.val(),
  55. lastName: $lastName.val(),
  56. email: $email.val(),
  57. password: $password.val(),
  58.  
  59. };
  60.  
  61. $.ajax({
  62. type: "POST",
  63. url: "http://rest.learncode.academy/api/register/user",
  64. data: user,
  65. success: function(newUser) {
  66. addUser(user);
  67. },
  68. error: function() {
  69. alert("Error saving data.");
  70. }
  71.  
  72. });
  73. });
  74.  
  75.  
  76.  
  77. });
  78.  
  79. <div id="container">
  80. <header>
  81. <h1>Registration Completed!</h1>
  82. <hr>
  83. </header>
  84. <article>
  85. <div id="info">
  86. <p>Thank you for registering on our site! An verification email has been seen to your email address! To make sure we got everything right, we would like you to review the infomation you've put in.</p>
  87. <div id="data">
  88.  
  89. </div>
  90. </div>
  91. </article>
  92. <footer>
  93. Copyright @ 2017
  94. </footer>
  95. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement