-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
42 lines (36 loc) · 1.02 KB
/
main.js
File metadata and controls
42 lines (36 loc) · 1.02 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
let login_btn = document.getElementById('login_btn')
login_btn.addEventListener("click", login);
if(sessionStorage.getItem('id') == null) {
login_btn.innerText = "로그인";
} else if (sessionStorage.getItem('id') != "") {
login_btn.innerText = sessionStorage.getItem("name") + "님";
}
load();
function load() {
$.ajax({
url: 'main.php',
type: 'POST',
data: {
},
success: function (data) {
$(".para").html(data);
},
error: function (e) {
alert(e.reponseText);
}
});
}
function login() {
if (sessionStorage.getItem('id') == "" || sessionStorage.getItem('id') == null) {
location.href = "login.html";
} else {
alert("로그아웃 되었습니다.");
sessionStorage.id = "";
sessionStorage.name = "";
login_btn.innerText = "로그인";
}
}
function toBuy(e) {
let w_id = e.target.id;
window.open(`./buying.html?${w_id}`);
}