alaajabari commited on
Commit
c4da4c0
·
verified ·
1 Parent(s): 99ae164

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +18 -9
static/script.js CHANGED
@@ -1,16 +1,25 @@
1
  async function runNER() {
2
- const text = document.getElementById("text").value;
 
3
 
4
- const response = await fetch("/predict", {
5
- method: "POST",
6
- headers: { "Content-Type": "application/json" },
7
- body: JSON.stringify({ text, mode: "1" })
8
- });
9
 
10
- const data = await response.json();
 
 
 
11
 
12
- document.getElementById("output").textContent =
13
- JSON.stringify(data, null, 2);
 
 
 
 
 
14
  }
15
 
16
 
 
1
  async function runNER() {
2
+ try {
3
+ const text = document.getElementById("text").value;
4
 
5
+ const response = await fetch("/predict", {
6
+ method: "POST",
7
+ headers: { "Content-Type": "application/json" },
8
+ body: JSON.stringify({ text, mode: "1" })
9
+ });
10
 
11
+ const raw = await response.text(); // 👈 IMPORTANT
12
+ console.log("RAW RESPONSE:", raw);
13
+
14
+ const data = JSON.parse(raw);
15
 
16
+ document.getElementById("output").textContent =
17
+ JSON.stringify(data, null, 2);
18
+
19
+ } catch (err) {
20
+ document.getElementById("output").textContent =
21
+ "NER Error: " + err.message;
22
+ }
23
  }
24
 
25