Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="container">
- <header>
- <h1>Registration Form</h1>
- <hr>
- </header>
- <article>
- <form action="completed.html" method="POST" accept-charset="ISO-8859-1">
- <label for="FirstName"><b>First Name:</b></label>
- <input id="FirstName" type="text" placeholder="John" required>
- <label for="LastName"><b>Last Name:</b></label>
- <input id="LastName" type="text" placeholder="Doe" required>
- <label for="email"><b>Email:</b></label>
- <input id="email" type="text" placeholder="example@mail.com" required>
- <label for="password"><b>Password:</b></label>
- <input id="password" type="password" placeholder="Password here." required>
- <p></p>
- <button id="addUser">Submit</button>
- </form>
- </article>
- <footer>
- Copyright @ 2017
- </footer>
- </div>
- $(function() {
- var $firstName = $("#FirstName");
- var $lastName = $("#LastName");
- var $email = $("#email");
- var $password = $("#password");
- var $data = $("#data");
- $.ajax({
- type: "GET",
- url: "http://rest.learncode.academy/api/register/user",
- success: function(users) {
- $.each(users, function(i, user) {
- addUser(user);
- });
- },
- error: function() {
- alert("error loading user");
- }
- });
- function addUser() {
- $data.append(user.firstName + user.lastName + user.email + user.password);
- }
- $("#addUser").on("click", function() {
- var user = {
- firstName: $firstName.val(),
- lastName: $lastName.val(),
- email: $email.val(),
- password: $password.val(),
- };
- $.ajax({
- type: "POST",
- url: "http://rest.learncode.academy/api/register/user",
- data: user,
- success: function(newUser) {
- addUser(user);
- },
- error: function() {
- alert("Error saving data.");
- }
- });
- });
- });
- <div id="container">
- <header>
- <h1>Registration Completed!</h1>
- <hr>
- </header>
- <article>
- <div id="info">
- <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>
- <div id="data">
- </div>
- </div>
- </article>
- <footer>
- Copyright @ 2017
- </footer>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement