코딩하는 문과생
[Web] 10. MVC 패턴 - AJAX 통신(2) 본문
[Document에서 스크립트로 비동기 통신]

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<!-- a태그를 이용해 매개변수를 포함해 함수를 호출할 수 있다. -->
<a href="javascript:test('sijune', 10)">링크</a>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
//링크를 걸어 다른페이지가 아닌 Modal을 띄워야 하는 상황이 발생할 경우
function test(id, age) {
alert(id + ", " + age);
$.ajax({
url : '',
type : "",
data : { id : id, age : age},
dataType : "json",
success : function(obj) {
}
});
}
</script>
</body>
</html>

'웹 프로그래밍 > Web' 카테고리의 다른 글
[Web] 차이냐오 API, 중국 알리바바 I/F 삽질기 (0) | 2022.07.07 |
---|---|
[Web] 9. MVC 패턴 - AJAX 통신 (0) | 2020.02.03 |
[Web] 8. Json 통신 (0) | 2020.01.31 |
[Web] 7. MVC 패턴(6) - 세션을 이용한 로그아웃 기능 (0) | 2020.01.31 |
[Web] 6. MVC 패턴(5) - 데이터를 심기 위한 session (0) | 2020.01.31 |