js/jQuery
js(jQuery) Ajax ,Test_003 하기, (http Get method 사용하여 data 읽어 오기)
sucun
2022. 6. 19. 23:18
html 파일
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="./index_ajaxTest_Get_003.js"></script>
</head>
<body>
<button>Send an HTTP GET request to a page and get the result back</button>
</body>
</html>
jQuery 파일
/**
* js(jQuery) Ajax ,Test_003 하기, (http Get method 사용하여 data 읽어 오기)
* TODO:
* , js -> 렌더링 순서 , html -> head -> body , (CSS -> DOM 순서), 외부 링크 CSS 먼저/ Script body 아래 추천
* , js -> ajax(test)
* , 참고사이트 : https://www.w3schools.com/jquery/jquery_ajax_load.asp
*/
$(document).ready(function () {
$("button").click(function () {
url = "https://jsonplaceholder.typicode.com/todos/20";
// $.get("demo_test.asp", function (data, status) {
$.get(url, function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
console.log("data: ", JSON.stringify(data));
});
});
});
반응형