-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasyncTests.html
43 lines (40 loc) · 1.23 KB
/
asyncTests.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
<!DOCTYPE html>
<html>
<p id="response"></p>
<script src="js/jquery-3.7.1.min.js"></script>
<script>
const url = "https://restaurierungsvokabular.solidweb.org/wuerste/krakauer.ttl";
async function getData(url) {
try {
let response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
let text = await response.text();
//console.log(text);
return text;
} catch (error) {
console.error(error.message);
}
}
async function getAjaxData(url) {
let result;
try {
result = await $.ajax({
url: url,
type: 'GET'
});
return result;
} catch (error) {
console.error(error);
}
}
async function twoAsyncs() {
const text1 = await getAjaxData(url);
const text2 = await getAjaxData(url);
const text = text1 + text2;
$("#response").text(text);
}
twoAsyncs()
</script>
</html>