Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. generateUploadCallback: function(onUploadSuccess) {
  2.         return function () {
  3.             var form       = <HTMLFormElement> document.getElementById('uploadForm');
  4.             var formData   = new FormData(form);
  5.             // TODO: fail if the user selected more than one file
  6.  
  7.             $.ajax(
  8.                 {
  9.                     url        : '/web/upload',
  10.                     type       : 'POST',
  11.                     data       : formData,
  12.                     processData: false,
  13.                     contentType: false,
  14.                     cache      : false,
  15.                     success    : onUploadSuccess,
  16.                     error      : function (request, status, error) {
  17.                         console.error(
  18.                             `MOEsaic upload: ${error}\n${request.responseText}`
  19.                         );
  20.  
  21.                         moesaic.ui.message_dialog.show(
  22.                             'Server ERROR',
  23.                             'Upload failed.',
  24.                             function() {
  25.                                 // return to the default upload page
  26.                                 window.location.href = 'moesaic.html';
  27.                             }
  28.                         );
  29.                     }
  30.                 }
  31.             );
  32.         };
  33.     },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement