Fix: send request / receive json data

This commit is contained in:
2018-07-10 18:03:46 +09:00
parent 7fe64c7a45
commit b5b56e8c2d
8 changed files with 175 additions and 87 deletions
+26 -28
View File
@@ -10,6 +10,7 @@
<script type="text/javascript" src="./../../../resources/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="./../js/main.js"></script>
<script type="text/javascript" src="./../js/request_server.js"></script>
<script type="text/javascript">
$(document).ready(function() {
sessionStorage.setItem("maestroID", -1);
@@ -21,30 +22,25 @@
let name = $("#maestro_name").val();
let password = $("#password").val();
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/maestro/login.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_name=" + name + "&password=" + password);
xhr.onload = function() {
if(xhr.readyState === 4 && xhr.status === 200) {
let replyJSON = JSON.parse(xhr.responseText);
// console.log(replyJSON);
// if(replyJSON !== null)
// console.log(replyJSON);
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/login.php",
"maestro_name=" + name + "&password=" + password,
// if(replyJSON["MaestroID"] !== undefined)
// console.log(replyJSON["MaestroID"]);
(jsonData) => {
maestroID = jsonData["MaestroID"];
sessionStorage.setItem("maestroID", maestroID);
location.href = 'admin_register_list.html';
},
if(replyJSON !== null && replyJSON["MaestroID"] !== undefined && replyJSON["MaestroID"] !== null) {
maestroID = replyJSON["MaestroID"];
sessionStorage.setItem("maestroID", maestroID);
location.href = 'admin_register_list.html';
} else {
$("#error_message").val(replyJSON["ERROR"]);
(errorMessage) => {
if($("#error_message").length) {
$("#error_message").text(errorMessage);
}
}
}
);
}
</script>
@@ -54,17 +50,19 @@
<body bgcolor="white">
<div>
관리자 아이디
<input type="text" id="maestro_name" name="maestro_name"><br/>
암호
<input type="password" id="password" name="password"><br/>
</div>
<div>
관리자 아이디
<input type="text" id="maestro_name" name="maestro_name"><br/>
암호
<input type="password" id="password" name="password"><br/>
</div>
<div class="col alignCenter">
<a id="login" class="btn btn-sea width400" onClick="login()">로그인</a>
</div>
<div class="col alignCenter">
<a id="login" class="btn btn-sea width400" onClick="login()">로그인</a>
</div>
<div id="error_message">
</div>
</body>