Fix: move addPlayer function
This commit is contained in:
@@ -4,11 +4,15 @@ let playerListPage = 0;
|
||||
let lastPageNo = 0;
|
||||
|
||||
let addPlayerList;
|
||||
let searchPlayerList;
|
||||
|
||||
let addPlayerListNavigator;
|
||||
|
||||
let searchPlayerList;
|
||||
let searchPlayerListNavigator;
|
||||
|
||||
let mouseAppList;
|
||||
|
||||
let typingAppList;
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
maestroID = sessionStorage.getItem("maestroID");
|
||||
@@ -94,51 +98,3 @@ function tabClicked(tabNo) {
|
||||
}
|
||||
}
|
||||
|
||||
function addPlayer() {
|
||||
// let maestroID = sessionStorage.getItem("maestroID");
|
||||
let playerName = $("#add_player_name").val();
|
||||
let enterCode = $("#add_player_enter_code").val();
|
||||
|
||||
if(playerName.length === 0) {
|
||||
$("#add_player_notice").val("학생 이름을 입력하세요.");
|
||||
$("#add_player_name").focus();
|
||||
} else if(enterCode.length === 0) {
|
||||
$("#add_player_notice").val("엔터 코드를 입력하세요.");
|
||||
$("#add_player_enter_code").focus();
|
||||
}
|
||||
|
||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||
xhr.open('POST', './../server/user/add_player.php', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName + "&enter_code=" + enterCode);
|
||||
xhr.onload = function() {
|
||||
if(xhr.readyState === 4 && xhr.status === 200) {
|
||||
// console.log(xhr.responseText);
|
||||
// console.log(xhr.responseText.length);
|
||||
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
// console.log(replyJSON);
|
||||
|
||||
if(replyJSON === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
||||
console.log(replyJSON["ERROR"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["RESULT"] === "fail") {
|
||||
console.log(replyJSON["RESULT"]);
|
||||
return;
|
||||
}
|
||||
|
||||
loadPlayerListPage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user