获得onComplete方法后,我发现我的responseJSON变量似乎不包含我预期的信息。这是我在某个地方(可能),或不正常工作的东西吗? FineUploader正在识别一个成功的上传,所以我知道它得到的响应,但当我记录responseJSON在onComplete,它打印responseJSON:。只是文件名。无括号,括号等。
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.
客户端代码
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编辑:我还为FineUploader-3.3.0.js文件添加了一个日志,它接收到正确的JSON对象,它只是不传递它
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.
推荐答案onComplete方法的第一个参数实际上是事件,所以你真的引用 fileName 与 responseJSON 。如果您更改方法参数以包含该事件,我认为应该可以正常工作。
The first parameter on the onComplete method is actually the event, so you're really referencing fileName with responseJSON. If you change your method parameters to include the event, I think that should work.
uploader.on "complete", (event, id, fileName, responseJSON)更多推荐
FineUploader responseJSON在onComplete回调中不包含成功
发布评论