Fix: revised php code to maestro search
This commit is contained in:
@@ -1,63 +1,43 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
addPlayerListManager = new PlayerListManager(
|
||||
$("#add_player_list"),
|
||||
$("#add_player_list_navigator > #page_no_area")
|
||||
);
|
||||
// addPlayerListNavigator = new PlayerListNavigator($("#add_player_list_navigator > #page_no_area"));
|
||||
// addPlayerList = new PlayerList($("#add_player_list"), addPlayerListNavigator);
|
||||
|
||||
// addPlayerList.loadPlayerListPage(1);
|
||||
addPlayerListManager.setupAddPlayerList();
|
||||
});
|
||||
|
||||
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();
|
||||
return;
|
||||
} else if(enterCode.length === 0) {
|
||||
$("#add_player_notice").val("엔터 코드를 입력하세요.");
|
||||
$("#add_player_enter_code").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||
xhr.open('POST', './../server/player/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;
|
||||
}
|
||||
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||
"./../server/player/add_player.php",
|
||||
"maestro_id=" + maestroID + "&player_name=" + playerName + "&enter_code=" + enterCode,
|
||||
|
||||
(jsonData) => {
|
||||
addPlayerListManager.updateAddPlayerListPage(1);
|
||||
},
|
||||
|
||||
(errorMessage) => {
|
||||
if($("#error_message").length) {
|
||||
$("#error_message").text(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -72,7 +52,7 @@ function addPlayer() {
|
||||
<div>
|
||||
학생 이름 <input type="text" name="name" id="add_player_name"><br/>
|
||||
입장 코드 <input type="text" name="entercode" id="add_player_enter_code">
|
||||
<input type="submit" name="추가" onClick="addPlayer()">
|
||||
<input type='button' value="추가"" onClick="addPlayer()" >
|
||||
</div>
|
||||
|
||||
<textarea id="add_player_notice">
|
||||
|
||||
Reference in New Issue
Block a user