After getting the onComplete method to fire, I found that my responseJSON variable does not appear to contain the information I expected it to. Is this me screwing up somewhere(probably), or something not working quite right? FineUploader is recognizing a successful upload, so I know its getting the response, but when I log responseJSON in the onComplete, it prints "responseJSON: ". Just the file name. no braces, brackets, etc.
Client Side Code
uploader = new $("#collaboration-fine-uploader").fineUploader
autoUpload: false
multiple: false
validation:
allowedExtensions: ['pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']
sizeLimit: 1024*1024*1024*10 # 10MB
text:
uploadButton: "<i class='icon-plus icon-white'></i> Select Files"
request:
endpoint: "/files/discussions/collaborations/upload"
uploader.on "complete", (id, fileName, responseJSON) ->
console.log "responseJSON: "+responseJSON
if (responseJSON.success)
discussionId = responseJSON.discussionId
$.ajax
type: "GET"
url: "/courses/"+serverData.course._id+"/discussions/"+discussionId
beforeSend: (xhr) ->
xhr.setRequestHeader 'x-pjax', 'true'
success: (html) ->
# Replace the old html
$(".discussions-tab").html html
$(".new-discussion").slideUp()
$("#new-discussion-modal").deactivateModal()
# History push
window.history.pushState window.history.state, "Discussions", "/courses/"+serverData.course._id+"/discussions/"+discussionId
# Scroll to top
$.scrollTo 0
Server side Response Code (just the necessary part)
response =
"success": true
"discussionId": discussion.id
console.log JSON.stringify response
res.send JSON.stringify response
EDIT: I've also added a log to the FineUploader-3.3.0.js file, and it is receiving the correct JSON object, it is just not passing it back correctly for some reason.
The first parameter on the onComplete method is actually the event, so you're really referencing
fileName
withresponseJSON
. If you change your method parameters to include the event, I think that should work.