Advertisement
codemonkey

Failing completeHandler

May 16th, 2012
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. completeHandler = (e, data)->
  2.     # If the upload didn't succeed, inform the user and display debug
  3.     # information in the console
  4.     if data.textStatus != 'success'
  5.         alert "Noe gikk galt. Debug informasjon er logget i konsollen"
  6.         console.group 'Upload failure'
  7.         console.error data.textStatus
  8.         console.error data.result
  9.         console.groupEnd 'Upload failure'
  10.  
  11.         # Un-disable the buttons
  12.         selectButton.removeClass 'disabled'
  13.         uploadButton.removeClass 'disabled loading'
  14.         uploadButton.html 'Last opp'
  15.  
  16.         return
  17.  
  18.     # Save the response of the file upload
  19.     self.fileUploadResponse = data.result
  20.  
  21.     # Fetch a preview of the uploaded file
  22.     url = "#{config.api_root}/#{config.api_path_tabulardatafilepreview}"
  23.     $.ajax url,
  24.         type: 'POST'
  25.         dataType: 'json'
  26.         async: false
  27.         data:
  28.             'file_handle': data.result.file_handle
  29.             'rownum': 5
  30.  
  31.         complete: (req, text_status)->
  32.             # Handle errors
  33.             if text_status != 'success'
  34.                 alert "Noe gikk galt. Debug informasjon er logget " + \
  35.                       "i konsollen"
  36.                 console.group 'Failed to receive data file preview'
  37.                 console.log text_status
  38.                 console.log req.responseText
  39.                 console.log req
  40.                 console.groupEnd 'Failed to receive data file preview'
  41.  
  42.                 # Un-disable the buttons
  43.                 selectButton.removeClass 'disabled'
  44.                 uploadButton.removeClass 'disabled loading'
  45.                 uploadButton.html 'Last opp'
  46.  
  47.             # Save the preview data and initiate stage 2
  48.             self.previewData = JSON.parse req.responseText
  49.             self.setStage 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement