-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (32 loc) · 971 Bytes
/
script.js
File metadata and controls
38 lines (32 loc) · 971 Bytes
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
complete_page= document.querySelector(".complete_page"),
web_page = document.querySelector(".web_page"),
form = document.querySelector("form"),
selectbtn = form.querySelector(".submit"),
form_page = document.querySelector(".form_page");
function enroll(){
web_page.style.display= "none";
form_page.style.display= "block";
}
function cancel(){
web_page.style.display= "block";
form_page.style.display= "none";
}
form.onsubmit= (e)=>{
e.preventDefault();
}
selectbtn.onclick= ()=>{
let xhr = new XMLHttpRequest();
xhr.open("POST", "enroll.php", true);
xhr.onload= ()=>{
if(xhr.readyState === XMLHttpRequest.DONE){
if(xhr.status === 200){
let data = xhr.response;
if(data == "success"){
cancel();
}
}
}
}
let formdata = new FormData(form);
xhr.send(formdata);
}