philipobiorah commited on
Commit
0e74490
·
verified ·
1 Parent(s): 47b6497

use ajax to fix result display via input

Browse files
Files changed (1) hide show
  1. 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
- $.post("/analyze_text", { text: $("#text").val() }, function(response) {
179
- $("#text-progress-bar").css("width", "100%").text("Done!");
180
- $(".loading").hide();
181
- $("#sentiment").text(response.sentiment).attr("class", response.sentiment.toLowerCase());
182
- }).fail(function() {
183
- $("#textError").text("Error: Could not analyze text.");
 
 
 
 
 
 
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