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
-10
View File
@@ -1,10 +0,0 @@
<?php
function send_error_code($error_code) {
$returnValue = array(
'error' => $error_code
);
echo json_encode($returnValue, JSON_UNESCAPED_UNICODE);
}
?>
+35
View File
@@ -0,0 +1,35 @@
<?php
$jsonReply = null;
function set_error_message($message) {
global $jsonReply;
$jsonReply["error"] = $message;
}
function set_data($name, $data) {
global $jsonReply;
$jsonReply[$name] = $data;
}
function send_result_success() {
global $jsonReply;
global $db_conn;
$jsonReply["result"] = "success";
echo json_encode($jsonReply, JSON_UNESCAPED_UNICODE);
$db_conn->close();
}
function send_result_fail() {
global $jsonReply;
global $db_conn;
$jsonReply["result"] = "fail";
echo json_encode($jsonReply, JSON_UNESCAPED_UNICODE);
$db_conn->close();
}
?>