-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
86 lines (66 loc) · 2.47 KB
/
index.js
File metadata and controls
86 lines (66 loc) · 2.47 KB
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
//ajax call for the sign up form
//once the form is submited
$("#signupForm").submit(function(event){
//prevent default php processing
event.preventDefault();
//collect user inputs
var datatopost = $(this).serializeArray();
//send them to signup.php using AJAX
$.ajax({
url: "signup.php",
type: "POST",
data: datatopost,
success: function(data){//AJAX call successful: show error or success message
if(data){
$("#signupmessage").html(data);
}
},
error:function(){//AJAX call fails: show AJAX call error
$("#signupmessage").html("<div class='alert alert-danger'>There was an error with the AJAX call. Please try again later!</div>");
},
});
});
//ajax call for the login form
//once the form is submited
$("#loginForm").submit(function(event){
//prevent default php processing
event.preventDefault();
//collect user inputs
var datatopost = $(this).serializeArray();
//send them to login.php using AJAX
$.ajax({
url: "login.php",
type: "POST",
data: datatopost,
success: function(data){//AJAX call successful
if(data == "success"){ //if php files return "success": redirect the user to the note page
window.location.href = "mainpagelogedin.php";
}else{ //otherwise show error message
$("#loginmessage").html(data);
}
},
error:function(){//AJAX call fails: show AJAX call error
$("#loginmessage").html("<div class='alert alert-danger'>There was an error with the AJAX call. Please try again later!</div>");
},
});
});
//ajax call for the forgot password form
//once the form is submited
$("#forgotPasswordForm").submit(function(event){
//prevent default php processing
event.preventDefault();
//collect user inputs
var datatopost = $(this).serializeArray();
//send them to forgotpassword.php using AJAX
$.ajax({
url: "forgotpassword.php",
type: "POST",
data: datatopost,
success: function(data){//AJAX call successful
$("#forgotpasswordmessage").html(data);
},
error:function(){//AJAX call fails: show AJAX call error
$("#loginmessage").html("<div class='alert alert-danger'>There was an error with the AJAX call. Please try again later!</div>");
},
});
});