0

我正在使用 Uploadify 3.1 并在单击上传按钮时收到错误“未捕获的类型错误:无法读取未定义的属性 'queueData'”。下面是我的代码。不确定是什么问题。

上传字段:

<input type="file" name="file_upload" id="file_upload"/>
<input type="button" class="batchImport" value="Upload Files"/>

Javascript:

$(document).on("click",".batchImportElements",function(){
        $("#objectDetails").hide().html("");
        $("#objectList").show();
        $("#objectList").html("<img src="images/loading.gif"/> Loading").show();
        $.ajax({
            type:"POST",
            data:{
                multiple:1
            },
            url:"/index.php/elements_handler/importElements",
            success:function(response){
                checkResponse(response);
                $("#objectList").html(response);

                $("#file_upload").uploadify({
                    "swf":"/js/uploadify-v3.1/uploadify.swf",
                    "uploader":"/js/uploadify-v3.1/uploadify.php",
                    "uploadFolder":"/uploads/",
                    "auto":false,
                    "multi":true,
                    "height":19,
                    "width":94,
                    "onUploadError":function(file,errorCode,errorMsg,errorString){
                        alert("The file " + file.name + " could not be uploaded: " + errorString);
                    },
                    "onUploadSuccess":function(file, data, response){
                        $.ajax({
                            type:"POST",
                            data:{
                                multiple:1,
                                companies_id:companies_id,
                                file:file,
                                data:data,
                                folderPath:1
                            },
                            url:"/index.php/elements_handler/importElements",
                            success:function(response){
                                checkResponse(response);
                            }
                        });
                    }
                });

                $(document).on("click",".batchImport",function(){
                    $(".batchImport").uploadify("upload");
                });
            }
        });
    });

`

$('.batchImport')是用于触发上传的按钮。任何帮助,将不胜感激。

4

1 回答 1

0

为什么要使用 id file_upload在文件控件上创建 uploadify ,然后使用类batchImport在按钮控件上调用上传?具有类batchImport的按钮未设置为 uploadify 控件,因此它应该引发错误。

// Your code
$("#file_upload").uploadify({
    ....                    
});

$(".batchImport").uploadify("upload");


// Should most likely be
$("#file_upload").uploadify({
    ....                    
});

$("#file_upload").uploadify("upload");
于 2012-07-25T12:34:03.477 回答