-
Notifications
You must be signed in to change notification settings - Fork 0
/
promise01.html
53 lines (46 loc) · 1.2 KB
/
promise01.html
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
<html>
<head>
<title>Promise</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
</head>
<body>
<p id="promise" class="promise"></p>
</body>
</html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
function oana01(){
return new Promise(function(resolve, reject){
setTimeout(function(){
console.warn('oana01');
resolve(true);
}, 20);
});
}
function oana02(){
return new Promise(function(resolve, reject){
setTimeout(function(){
console.warn('oana02');
resolve(true);
}, 10);
});
}
function oana03(){
return new Promise(function(resolve, reject){
setTimeout(function(){
console.warn('oana03');
resolve(true);
}, 30);
});
}
oana01().then(function(data) {
oana02().then(function(data) {
oana03();
});
});
});
</script>