use ajax to fix result display via input
Browse files- templates/upload.html +12 -6
templates/upload.html
CHANGED
@@ -175,12 +175,18 @@
|
|
175 |
$("#text-progress-bar").css("width", "50%").text("Processing...");
|
176 |
$(".loading").show();
|
177 |
|
178 |
-
$.
|
179 |
-
|
180 |
-
|
181 |
-
$("#
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
});
|
185 |
});
|
186 |
|
|
|
175 |
$("#text-progress-bar").css("width", "50%").text("Processing...");
|
176 |
$(".loading").show();
|
177 |
|
178 |
+
$.ajax({
|
179 |
+
url: "/analyze_text",
|
180 |
+
type: "POST",
|
181 |
+
data: { text: $("#text").val() },
|
182 |
+
success: function(response) {
|
183 |
+
$("#text-progress-bar").css("width", "100%").text("Done!");
|
184 |
+
$(".loading").hide();
|
185 |
+
$("#sentiment").text(response.sentiment).attr("class", response.sentiment.toLowerCase()).show();
|
186 |
+
},
|
187 |
+
error: function(xhr) {
|
188 |
+
$("#textError").text("Error: " + xhr.responseJSON.error);
|
189 |
+
}
|
190 |
});
|
191 |
});
|
192 |
|