서버- 클라이언트
내 컴으로 서버와 클라이언트 둘 다 돌려 보았다 ... 처음은 낯설었지만 점점 익숙해 질수록 재미 있다 ^^
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<title> 4주차 숙제 </title>
<link href="https://fonts.googleapis.com/css2?family=Sunflower:wght@300&display=swap" rel="stylesheet">
<style>
* {
font-family: 'Sunflower', sans-serif;
}
.product_image {
background-color: green;
width: 500px;
height: 300px;
margin: 30px auto 30px auto;
background-image: url("https://contents.lotteon.com/itemimage/LO/10/31/32/86/40/_1/03/13/28/64/1/LO1031328640_1031328641_1.jpg/dims/resizef/720X720");
background-size: cover;
background-position: center;
}
.pro_dis {
width: 500px;
margin: 0px auto 30px auto;
}
.btn {
width: 120px;
margin: auto auto 30px auto;
display: block;
}
.pro_forms {
width: 500px;
margin: auto;
}
.dropdown_wrap {
overflow: auto;
}
.dolor {
color: darkslateblue;
}
.dolor_1 {
display: block;
float: left;
}
.wrap {
margin: auto;
width: 500px;
}
</style>
<script>
$(document).ready(function () {
order_listing()
q1();
});
function q1() {
$.ajax({
type: "GET",
url: "https://api.manana.kr/exchange/rate.json",
data: {},
success: function (response) {
// console.log(response[1]['rate')
let lows = response[1]['rate']
let temp_html = `${lows}`
$('#rate').text(temp_html)
}
})
}
function order_listing() {
// 주문목록 보기 API 연결
$.ajax({
type: "GET",
url: "/order",
data: {},
success: function (response) {
let order_view = response['all_views']
for (let i = 0; i < order_view.length; i++) {
let name = order_view[i]['name']
let order_count = order_view[i]['order count']
let address = order_view[i]['address']
let mobile = order_view[i]['mobile']
let temp_html = `<tr>
<th scope="col">${name}</th>
<th scope="col">${order_count}</th>
<th scope="col">${address}</th>
<th scope="col">${mobile}</th>
</tr> `
$('#order-box').append(temp_html)
}
}
})
}
function order() {
let name = $('#name').val()
let order_count = $('#order-count').val()
let address = $('#address').val()
let mobile = $('#mobile').val()
$.ajax({
type: "POST",
url: "/order",
data: {name_give: name, order_give: order_count, address_give: address, mobile_give: mobile},
success: function (response) { // 성공하면
alert(response["msg"]);
window.location.reload();
}
})
}
</script>
</head>
<body>
<div class="wrap">
<div class="product_image">
</div>
<div class="pro_dis">
<h2> 장수 풍뎅이 <span class="badge badge-danger">5억 파운드/5마리</span></h2>
<h5>"날이면 날마다 오는게 아닙니다!”, “애들은 가라!", <p>“장수 풍데이 한 번 키워봐!"</p></h5>
</div>
<div class="pro_forms">
<div class="dolor">
<h6 class="dolor_1">달러 - 원 환율 :</h6>
<h6 id="rate"></h6>
</div>
<div class="form-group">
<label> <span class="badge badge-pill badge-primary">주문자 이름</span></label>
<input class="form-control" id="name">
</div>
<div class="form-group">
<div class="input-group-prepend">
<label class="badge badge-pill badge-success">수량</label>
</div>
<select id="order-count" class="custom-select">
<option selected>-- 수량을 선택하세요 --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="form-group">
<label><span class="badge badge-pill badge-success">주소</span></label>
<input class="form-control" id="address">
</div>
<div class="form-group">
<label><span class="badge badge-pill badge-success">전화번호</span></label>
<input class="form-control" id="mobile">
</div>
</div>
<div class="btn">
<button onclick="order()" class="btn btn-primary">주문하기</button>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">이름</th>
<th scope="col">수량</th>
<th scope="col">주소</th>
<th scope="col">전화번호</th>
</tr>
</thead>
<tbody id="order-box">
<tr>
<th scope="row">니체</th>
<td>3</td>
<td>디오니소스</td>
<td>010-1844-1015</td>
</tr>
<tr>
<th scope="row">헤겔</th>
<td>2</td>
<td>절대정신</td>
<td>010-1770-0827</td>
</tr>
<tr>
<th scope="row">사르트르</th>
<td>1</td>
<td>기투</td>
<td>010-1905-0621</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
코드를 입력하세요
Author And Source
이 문제에 관하여(서버- 클라이언트), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@purelyric/서버-클라이언트저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)