forked from Namslay26/E-Learning-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout.js
31 lines (26 loc) · 940 Bytes
/
about.js
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
sub=document.getElementById("submit")
var data
function submitForm() {
email=document.getElementById("email").value;
name=document.getElementById("name").value;
phone=document.getElementById("phone").value;
edu=document.getElementById("studying").value;
dom=document.getElementById("domain").value;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(xhttp.responseText);
showData();
}};
xhttp.open("POST", "about.php", true);
xhttp.send(JSON.stringify({ email : email, name : name, phone : phone, edu : edu, dom : dom }));
}
function showData() {
console.log(data);
if(data.status=="success")
{
alert("Yay we got your info! You'll be hearing from us in no time.")
}
else if(data.status=="userExists"){alert("We already have your information! Please patiently await a response")}
}
sub.addEventListener("click",submitForm)