-
Notifications
You must be signed in to change notification settings - Fork 2
/
Async working example.html
39 lines (31 loc) · 1.06 KB
/
Async working example.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
<!doctype html>
<html>
<head>
</head>
<body>
<button id="sync" onclick="request(false);">Synchronous button</button>
<br />
<button id="async" onclick="request(true);">Asynchronous button</button>
<div id="content"></div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script type="text/javascript">
var requesting = false;
function request(async) {
if (requesting) {
return;
}
requesting = true;
var content = $('#content');
content.text('Requesting ...');
$.ajax({
url: 'content.html',
async: async,
success: function(data) {
content.text(data);
requesting = false;
}
});
}
</script>
</body>
</html>