uploadify queueData error

I am using Uploadify 3.1 and am getting the error "Uncaught TypeError: Cannot read property 'queueData' of undefined" when clicking the upload button. Below is my code. Not sure what the problem is.

Upload field:

<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");
                });
            }
        });
    });

`

The $('.batchImport') is the button being used to fire the upload. Any help would be appreciated.


Why are you creating uploadify on the file control with the id file_upload then calling the upload on the button control with the class batchImport ? The button with class batchImport was not setup as an uploadify control so it should throw an error.

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

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


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

$("#file_upload").uploadify("upload");
链接地址: http://www.djcxy.com/p/46476.html

上一篇: 在mvc应用程序中上传Ajax文件

下一篇: uploadify queueData错误