1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
AJAX Introduction
 
- AJAX는 프로그래밍 언어가 아니다.
 
- AJAX는 웹 페이지로부터 웹 서버로 접근하기 위한 기술이다.
 
- AJAX는 Asynchronous JavaScript And XML의 약자이다(비동기 방식!!!)
 
 
 
How AJAX Works
 
Browser : 이벤트 발생(XMLHttpRequest 객체 생성, HttpRequest 전송)
 
Server : HTTPRequest 프로세스, response를 생성하고 데이터를 브라우저로 back
 
Browser : JavaScript를 사용해서 데이터를 리턴하는 프로세스, 페이지 내용 업데이트
 
 
 
<!DOCTYPE html>
 
<html>
 
<body>
 
<div id=”ajax”>
 
<h1>Ajax Test</h1>
 
<button type=“button” onclick=”loadDoc()”>content change</button>
 
</div>
 
 
 
<script>
 
function loadDoc(){
 
var xhttp = new XMLHttpRequest();
 
xhttp.onreadystatechange = function() {
 
  if (this.readyState == 4 && this.status == 200) {
 
    document.getElementById(“ajax”).innerHTML = this.responseText; 
 
  }
 
};
 
xhttp.open(“GET”, ”ajax_info.txt”, true);
 
xhttp.send();
 
}
 
</script>
 
 
 
</body>
 
</html>
cs


+ Recent posts