function sendRequestServer(url, sendParams, onSuccess, onFail, isDebugMode) {
	// console.log(url);
	// console.log(sendParams);
	// console.log(onSuccess);
	// console.log(onFail);
	// console.log(isDebugMode);

	var xhr = new XMLHttpRequest(); //new로 생성.
	xhr.open('POST', url, true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send(sendParams);
	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) {
				var errorMessage = "서버에서 요청을 수행하지 못했습니다.";
				var errorCode = "no_reply_from_server";
				printErrorMessage(errorMessage, errorCode, onFail, isDebugMode);
				return;
			}

			var jsonReply = JSON.parse(xhr.responseText);
			// console.log(jsonReply);

			if(jsonReply === null) {
				var errorMessage = "서버에서 데이터가 넘어오지 않았습니다.";
				var errorCode = "no_data_from_server";
				printErrorMessage(errorMessage, errorCode, onFail, isDebugMode);
				return;
			}

			if(!isSuccess(jsonReply)) {
				var errorMessage = getErrorMessage(jsonReply);
				var errorCode = jsonReply["error_code"];
				printErrorMessage(errorMessage, errorCode, onFail, isDebugMode);
				return;
			}

			onSuccess(jsonReply);
		}
	}
}

function isSuccess(jsonReply) {
	if(jsonReply["result"] === undefined)
		return false;

	if(jsonReply["result"] === "fail")
		return false;

	return true;
}

function getErrorMessage(jsonReply) {
	return jsonReply["error"];
}

function printErrorMessage(errorMessage, errorCode, onFail, isDebugMode) {
	if(onFail !== undefined && onFail !== null)
		onFail(errorMessage, errorCode);

	if(isDebugMode === true) {
		console.log("Error message : " + errorMessage);
		console.log("Error code : " + errorCode);
	}
}