-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16.js_callback_hell.html
More file actions
57 lines (53 loc) · 2.07 KB
/
Copy path16.js_callback_hell.html
File metadata and controls
57 lines (53 loc) · 2.07 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>콜백지옥</title>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
</head>
<body>
<button onclick="callBackHell()">콜백지옥버튼</button>
<script>
function callBackHell(){
$(document).ready(function(){
$.ajax({
url: 'https://jsonplaceholder.typicode.com/posts/1',
type: 'GET',
dataType: 'json',
success: function(a){
// ajax와 같은 서버데이터호출 함수는 response를 parsing 진행.
console.log("a : ", a);
$.ajax({
url: 'https://jsonplaceholder.typicode.com/posts/1',
type: 'GET',
dataType: 'json',
success: function(b){
console.log("b : ", b);
$.ajax({
url: 'https://jsonplaceholder.typicode.com/posts/1',
type: 'GET',
dataType: 'json',
success: function(c){
console.log("c : ", c);
},
error: function(e){
console.log(e);
}
})
},
error: function(e){
console.log(e);
}
})
},
error: function(e){
console.log(e);
}
})
});
console.log("hello world");
}
</script>
</body>
</html>