uploadify queueData错误

时间:2012-07-25 12:20:13

标签: jquery uploadify

我正在使用Uploadify 3.1并且在单击上传按钮时收到错误“Uncaught TypeError:无法读取未定义的属性'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')是用于触发上传的按钮。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分: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");