-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbutton2.html
More file actions
51 lines (44 loc) · 1.39 KB
/
button2.html
File metadata and controls
51 lines (44 loc) · 1.39 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
<!DOCTYPE html>
<html>
<head>
<title>node.js</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var timer = null;
function startCalcProcess() {
$('#result').html('');
if (timer)
clearInterval(timer);
timer = setInterval(function(){
var res = $('#result').html();
if (res == '') $('#result').html('.');
else if (res == '.') $('#result').html('..');
else if (res == '..') $('#result').html('...');
else if (res == '...') $('#result').html('....');
else if (res == '....') $('#result').html('.....');
else $('#result').html('');
}, 300);
}
function stopCalcProcess(){
if (timer)
clearInterval(timer);
}
function getResult(){
startCalcProcess();
$.ajax({
url: "http://127.0.0.1:8000/calc"
}).done(function(data) {
stopCalcProcess();
$('#result').html(data);
}).fail(function() {
stopCalcProcess();
$('#result').html('error');
});
}
</script>
</head>
<body>
<input type="button" value="Calc" onclick="getResult();" />
<div id="result"></div>
</body>
</html>