Delay submitting $Ajax formData in Production

时间:2016-04-04 18:08:30

标签: ajax node.js

I'm submitting a form via $ajax to Node.js, and then uploading from there to Dropbox.

Locally, the form submit hits the route to upload the file in my server almost instantly. However, when on Heroku, there is a pretty significant lag. I'm logging the moment the route is hit, and it can take several minutes. Feels like the client is processing all the formData before sending it server-side. Is this normal behavior? Obviously the wait time is shorter on smaller file sizes.

Is there a way to track the progress on this processing? I have a file progress bar that starts, once the route in my server is hit (uploading to DropBox). But before then, it just hangs and it confusing to the user.

angular-app.js

$.ajax({
  type : 'POST',
  url: path_to_server_to_process_form,
  data: formData,
  contentType: false,
  processData: false,
  success: function (data) {
      console.log(data)
  },
  error: function (e, error, errorMessage) {
    console.log(errorMessage);
  }
})

Node server.js

    server.post('/route_for_processing_form', function (req, res){ 
 // It takes a while before hitting this route. 
}

0 个答案:

没有答案