From 02f278e61c4d1d6a1c808183d066b2e93a2d87c0 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Tue, 30 May 2023 10:48:28 +0200 Subject: [PATCH] only alert once --- api/views/index.ejs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/views/index.ejs b/api/views/index.ejs index 5c5d3d28..a4a5c51e 100644 --- a/api/views/index.ejs +++ b/api/views/index.ejs @@ -145,6 +145,7 @@ } function connect() { + var received = false; var xhr = new XMLHttpRequest(); xhr.open("GET", "/connect", true); xhr.onreadystatechange = function () { @@ -162,7 +163,12 @@ // console.log(status) document.getElementById("connectedstatus").innerHTML = "Connected: " + status.connected; } - alert("Could not connect to API!"); + if (!received) + { + alert("Could not connect to API!"); + received = true; + + } } }; xhr.send();