Spaces:
Running
Running
Robin
commited on
Commit
·
0c8c8bf
1
Parent(s):
ff2dd73
space trigger
Browse files- static/index.html +12 -1
static/index.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
<button id="sendRequest">Send Request</button>
|
12 |
<pre id="demo_output"></pre>
|
13 |
<script>
|
14 |
-
|
15 |
const value1 = document.getElementById("value1Input").value;
|
16 |
const DEMO_JSON = {
|
17 |
"key1": value1,
|
@@ -34,6 +34,17 @@
|
|
34 |
.catch(error => {
|
35 |
document.getElementById("demo_output").innerHTML = 'Error: ' + error;
|
36 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
});
|
38 |
</script>
|
39 |
</body>
|
|
|
11 |
<button id="sendRequest">Send Request</button>
|
12 |
<pre id="demo_output"></pre>
|
13 |
<script>
|
14 |
+
function sendRequest() {
|
15 |
const value1 = document.getElementById("value1Input").value;
|
16 |
const DEMO_JSON = {
|
17 |
"key1": value1,
|
|
|
34 |
.catch(error => {
|
35 |
document.getElementById("demo_output").innerHTML = 'Error: ' + error;
|
36 |
});
|
37 |
+
}
|
38 |
+
|
39 |
+
// Trigger on button click
|
40 |
+
document.getElementById("sendRequest").addEventListener("click", sendRequest);
|
41 |
+
|
42 |
+
// Trigger on Enter key in input field
|
43 |
+
document.getElementById("value1Input").addEventListener("keypress", function(event) {
|
44 |
+
if (event.key === "Enter") {
|
45 |
+
event.preventDefault();
|
46 |
+
sendRequest();
|
47 |
+
}
|
48 |
});
|
49 |
</script>
|
50 |
</body>
|