mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-11-22 07:58:02 +01:00
Add timeout to javascript queries
This commit is contained in:
parent
3e936313d5
commit
372cf830ae
1 changed files with 3 additions and 5 deletions
|
@ -1,13 +1,11 @@
|
||||||
function play() {
|
function play() {
|
||||||
console.log("Play...");
|
console.log("Play...");
|
||||||
var xhttp = new XMLHttpRequest();
|
fetch("/play", { signal: AbortSignal.timeout(7000) });
|
||||||
xhttp.open("GET", "play", true);
|
|
||||||
xhttp.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAvailableFiles() {
|
function loadAvailableFiles() {
|
||||||
console.log("Available files...");
|
console.log("Available files...");
|
||||||
fetch("/available-files")
|
fetch("/available-files", { signal: AbortSignal.timeout(7000) })
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(handleAvailableFiles);
|
.then(handleAvailableFiles);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +14,7 @@ function selectFile(name) {
|
||||||
console.log("Select file");
|
console.log("Select file");
|
||||||
const body = new FormData();
|
const body = new FormData();
|
||||||
body.set("fileName", name);
|
body.set("fileName", name);
|
||||||
fetch("/select-file", {method: "POST", body: body})
|
fetch("/select-file", { method: "POST", body: body, signal: AbortSignal.timeout(7000) })
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(handleAvailableFiles);
|
.then(handleAvailableFiles);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue