๋ก๋๋ฒํธ์์ฒญ.html ์์ฑ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>๋ก๋๋ฒํธ์์ฒญ</title>
<!-- ์ ์ด์ฟผ๋ฆฌCDN -->
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"
></script>
</head>
<body>
<div class="container">
<div id="result"></div>
</div>
<script>
$.ajax({
url: "https://www.dhlottery.co.kr/common.do?method=getLottoNumber&drwNo=1087", //์๋ฒ์ URL์ฃผ์
method: "GET", // HTTP ์์ฒญ ๋ฐฉ์(GET,POST)
dataType: "json", // ์๋ฒ์์ ๋ณด๋ด์ค ๋ฐ์ดํฐ์ ํ์
}).done(function (data) {
// .done ์์ ์๋ฃ๋ฅผ ๋ฐ๋๊ฒ ์ฑ๊ณตํ์ ๊ฒฝ์ฐ
console.log(data); //์ฑ๊ณต ์ ๋ฐ์ดํฐ ์ฝ์๋ก ์ถ๋ ฅ
});
</script>
</body>
</html>
https://kadosholy.tistory.com/23
๋ก๋ api๋ฅผ ์ด์ฉํ์ฌ ๋ก๋๋ฒํธ ๊ฐ์ ธ์ค๊ธฐ
๋ก๋ api๋ฅผ ์ด์ฉํ์ฌ ๋ก๋๋ฒํธ ๊ฐ์ ธ์ค๊ธฐ ๋ก๋ ๊ด๋ จ ์ฑ์ด๋ ํ๋ก๊ทธ๋จ์ ๋ง๋๋ ค๊ณ ํ๋ฉด ๋ก๋ ๋น์ฒจ๋ฒํธ๋ฅผ ์ ํ์๊ฐ ์๋๋ฐ ํ์ฌ ๋ณต๊ถ ํ๋งค ํํ์ด์ง๋ ๊ด๋ จ ์น ์ฌ์ดํธ๋ฅผ ์ฐพ์๋ด๋ ๊ณต์์ ์ผ๋ก ๋ก๋
kadosholy.tistory.com

CORS ์๋ฌ ๋ณด์์๋ฌ์
๐ ์ ๋ช ๋์ CORS ๊ฐ๋ & ํด๊ฒฐ๋ฒ - ์ ๋ฆฌ ๋ํ์ ๐
์ ๋ช ๋์ CORS ์๋ฌ ๋ฉ์ธ์ง ์น ๊ฐ๋ฐ์ ํ๋ค๋ณด๋ฉด ๋ฐ๋์ ๋ง์ฃผ์น๋ ๋ฉ๋ฉ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ๋ก CORS ์ด๋ค. ์น ๊ฐ๋ฐ์ ์ ์ ์ ๊ณ ์์ด๋ผ๊ณ ํ ์ ๋๋ก, CORS๋ ๋๊ตฌ๋ ํ ๋ฒ ์ ๋๋ ๊ฒช๊ฒ ๋๋ค๊ณ ํด๋ ๊ณผ์ธ์ด
inpa.tistory.com
Allow CORS: Access-Control-Allow-Origin
Easily add (Access-Control-Allow-Origin: *) rule to the response header.
chrome.google.com

ํ์ฑํ ํ๋ฉด

์ ์ฌ์ฉ๋๋ค.
ํ์ง๋ง ํ์ฅํ๋ก๊ทธ๋จ์ด ๊ทผ๋ณธ์ ์ธ ํด๊ฒฐ์ฑ ์ ์๋๋ผ๊ณ ํจ.
๊ฐ์ฒด๋ ํ๋๋ผ ๋ฐ๋ณต๋ฌธ ์ฌ์ฉํ ํ์์์ด ๋ฐ๋ก ๊ฐ์ ๊ฐ์ ธ์ด

ํ์ฅํ๋ก๊ทธ๋จ ์ฌ์ฉ์ํ๋ฉด ๊บผ์ผํจ
'FRONTEND > ๊ธฐํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| (APIํ์ฉ) ๊นํ๋ธ ์ ์ ์ฐพ๊ธฐ app 1 (1) | 2023.11.14 |
|---|---|
| AJAX ๊ธฐ๋ณธ ๊ฐ๋ ๋ฐ ์์ (1) | 2023.10.16 |
| jQuery ๋ฅผ ํ์ฉํด AJAX ์ฌ์ฉ load() (1) | 2023.10.06 |
| Dom ์์ฉ์ค์ต (1) | 2023.10.05 |
| jQuery - event (0) | 2023.10.05 |