Skip to content

Commit

Permalink
Fix some bugs with the ajax calls
Browse files Browse the repository at this point in the history
  • Loading branch information
steven1046 committed Nov 8, 2018
1 parent 9bece97 commit 5c7487a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/main/webapp/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ $(document).ready(function() {
$.ajax({
url: "rest/speech/check/" + id,
type: "GET",
data: formData,
async: false,
processData: false,
success: function(response){
// Insert the uploaded audio file in the audio portion.
num_tries--;
deferred.resolve(response);
// Insert the uploaded audio file in the audio portion.
num_tries--;
if(response.indexOf('false') > -1){
setTimeout(function(){
return pollForTranscript(id, num_tries);
}, 1000);
}
else{
deferred.resolve(id);
}
},
error: function(){
num_tries--;
Expand All @@ -77,7 +82,7 @@ $(document).ready(function() {
};

var retrieveTranscript = function(id) {
var deferred = $.deferred();
var deferred = $.Deferred();
$.ajax({
url: "rest/speech/" + id + "/transcript",
type: "GET",
Expand Down Expand Up @@ -106,7 +111,7 @@ $(document).ready(function() {
reader.readAsDataURL(this.files[0]);
uploadFile(this.files[0]).then(function(id){
// Poll for updates using the token
pollForTranscript(id).then(function(id){
pollForTranscript(id, 10).then(function(id){
// Retrieve the transcript
retrieveTranscript(id).then(function(response){
// Show the transcript on the page.
Expand Down

0 comments on commit 5c7487a

Please sign in to comment.