-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathdemo.html
55 lines (48 loc) · 1.99 KB
/
demo.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
54
55
<!DOCTYPE html>
<html>
<head>
<title>Ajax Progress</title>
<!-- Meta -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<!-- Google CDN -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/black-tie/jquery-ui.css" />
<script src="js/jquery.ajax-progress.js"></script>
<script>
$(function() {
$('#prog').progressbar({ value: 0 });
$.ajax({
method: 'GET',
url: 'data/bird.json',
dataType: 'json',
success: function() {
console.log('YAYE!', arguments[0]);
},
error: function() {
console.log('AWWW!');
},
progress: function(e) {
if(e.lengthComputable) {
var pct = (e.loaded / e.total) * 100;
$('#prog')
.progressbar('option', 'value', pct)
.children('.ui-progressbar-value')
.html(pct.toPrecision(3) + '%')
.css('display', 'block');
} else {
console.warn('Content Length not reported!');
}
}
});
});
</script>
</head>
<body>
<div id="prog"></div>
</body>
</html>