drbvm26000 2016-07-04 23:45
浏览 141

无法从dropzone.js并行上传获取服务器响应

I'm trying to get the server response from a set of uploads using dropzone.js parallel uploading so that I can maintain the uploader's intended file order as I register the files in a mySQL database. My files are being uploaded just fine, and the "successmultiple" event is being fired as expected - but server response is empty.

jQuery(document).ready(function() {
    Dropzone.autoDiscover = false;
    var filedrop = new Dropzone("#filedrop", {
        parallelUploads: 2,
        uploadMultiple: true,
        init: function() {
            this.on("successmultiple", function(files, response) {
                console.log(response);
            });
        },
        url: "upload2.php"
    });
});

If I assume the response is json and attempt to parse it as such:

               var json = $.parseJSON(response);
                $(json).each(function(i,val){
                        $.each(val,function(k,v){
                                console.log(k+" : "+ v);     
                        });
                });

I get a Uncaught SyntaxError: Unexpected end of JSON input error. Is the response empty because I haven't echo'd anything from my upload2.php file? I'd like to get a response that gives me information about file order while retaining the important ability to do parallel uploads. Am I completely barking up the wrong tree trying to determine the file order with server response? Are there any dropzone.js experts in the wings?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP