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
+27 -13
View File
@@ -25,11 +25,11 @@
let maestroName = $("#search_name").val();
if(maestroName.length === 0) {
// $("#search_name_notice").val("학생 이름을 입력하세요.");
$("#error_message").text("학생 이름을 입력하세요.");
$("#search_name").focus();
}
loadMaestroList($maestroName);
loadMaestroList(maestroName);
}
function loadMaestroList($maestroName) {
@@ -43,6 +43,7 @@
// console.log(xhr.responseText.length);
if(xhr.responseText.length === 0 || xhr.responseText === null) {
console.log("no data from server");
$("#error_message").text("서버에서 요청을 수행하지 못했습니다.");
return;
}
@@ -51,16 +52,19 @@
if(replyJSON === null) {
console.log("no data from server");
$("#error_message").text("서버에서 데이터가 넘어오지 않았습니다.");
return;
}
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
console.log(replyJSON["ERROR"]);
$("#error_message").text(replyJSON["ERROR"]);
return;
}
if(replyJSON["RESULT"] === "fail") {
console.log(replyJSON["RESULT"]);
$("#error_message").text(replyJSON["ERROR"]);
return;
}
@@ -138,6 +142,7 @@
// console.log(xhr.responseText.length);
if(xhr.responseText.length === 0 || xhr.responseText === null) {
console.log("no data from server");
$("#error_message").text("서버에서 요청을 수행하지 못했습니다.");
return;
}
@@ -146,20 +151,24 @@
if(replyJSON === null) {
console.log("no data from server");
$("#error_message").text("서버에서 데이터가 넘어오지 않았습니다.");
return;
}
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
console.log(replyJSON["ERROR"]);
$("#error_message").text(replyJSON["ERROR"]);
return;
}
if(replyJSON["RESULT"] === "fail") {
console.log(replyJSON["RESULT"]);
$("#error_message").text(replyJSON["ERROR"]);
return;
}
loadMaestroList("");
$("#error_message").text("마에스트로 계정이 정상적으로 등록되었습니다.");
}
}
}
@@ -177,19 +186,24 @@
</header>
<section id="section">
<span id="search_maestro_name">
<h1>검색</h1>
<div id="error_message">
</div>
마에스트로 이름
<input type="text" id="search_name"><input type="submit" name="찾기" onClick="searchMaestro()"><br/>
<br/>
</span>
<div>
<span id="search_maestro_name">
<h1>검색</h1>
<span id="search_result">
검색 결과
<div id="maestro_list_result_contents">
</div>
</span>
마에스트로 이름
<input type="text" id="search_name"><input type="submit" name="찾기" onClick="searchMaestro()"><br/>
<br/>
</span>
<span id="search_result">
검색 결과
<div id="maestro_list_result_contents">
</div>
</span>
</div>
</section>
</div>