FineUploader responseJSON在onComplete回调中不包含成功

编程入门 行业动态 更新时间:2024-10-23 11:29:13
本文介绍了FineUploader responseJSON在onComplete回调中不包含成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

获得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回调中不包含成功

本文发布于:2023-11-26 21:02:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635185.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:回调   中不   FineUploader   responseJSON   onComplete

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!