Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function register(user) {
- data = {
- action: 'register',
- username: $('input[name="username"]').val(),
- password: $('input[name="password"]').val(),
- firstname: $('input[name="firstname"]').val(),
- lastname: $('input[name="lastname"]').val(),
- email: $('input[name="email"]').val(),
- phonenumber: $('input[name="phonenumber"]').val()
- };
- if (user === 'buyer') {
- data.address = $('input[name="address"]').val();
- }
- $.ajax({
- type: "POST",
- url: user,
- data: data,
- success: function (response) {
- console.log(response);
- registrationCallback(JSON.parse(response));
- }
- });
- }
- function login(user) {
- data = {
- action: 'login',
- username: $('input[name="username"]').val(),
- password: $('input[name="password"]').val()
- };
- $.ajax({
- type: "POST",
- url: user,
- data: data,
- success: function (response) {
- loginCallback(JSON.parse(response));
- }
- });
- }
- function loginCallback(response) {
- if (response.code === '200') {
- window.location = '/ECoupon/' + response.data.url;
- } else {
- errorMessage(response.errors);
- }
- }
- function registrationCallback(response) {
- if (response.code == '201') {
- if (response.data.type === 'seller') {
- return;
- }
- window.location = '/ECoupon/' + response.data.url;
- } else {
- errorMessage(reponse.errors);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement