Dropbox uploader无法调用方法'提交'未定义的

时间:2013-01-06 14:34:44

标签: javascript jquery wordpress dropbox

我的Wordpress网站上的Dropbox上传器存在一些问题。

它给了我'未捕获的TypeError:无法在此行上调用'undefined'提交方法:

$('#fileupload')
        .bind('fileuploadstop', function (e, data) {
           //window.location.href = 'http://hiphopsmurf.com';
             $('#multimages', top.document).val(upfiles);
             parent.document.forms["multi_image"].submit();
             //parent.tb_remove();
        });

这是整个文档代码:

$(function () {
    'use strict';

    // Initialize the jQuery File Upload widget:
    $('#fileupload').fileupload();

    // Enable iframe cross-domain access via redirect option:
    $('#fileupload').fileupload(
        'option',
        'redirect',
        window.location.href.replace(
            /\/[^\/]*$/,
            '/cors/result.html?%s'
        )
    );

    if (window.location.hostname === 'blueimp.github.com') {
        // Demo settings:
        $('#fileupload').fileupload('option', {
            url: '//jquery-file-upload.appspot.com/',
            maxFileSize: 5000000,
            acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
            process: [
                {
                    action: 'load',
                    fileTypes: /^image\/(gif|jpeg|png)$/,
                    maxFileSize: 20000000 // 20MB
                },
                {
                    action: 'resize',
                    maxWidth: 1440,
                    maxHeight: 900
                },
                {
                    action: 'save'
                }
            ]
        });
        // Upload server status check for browsers with CORS support:
        if ($.support.cors) {
            $.ajax({
                url: '//jquery-file-upload.appspot.com/',
                type: 'HEAD'
            }).fail(function () {
                $('<span class="alert alert-error"/>')
                    .text('Upload server currently unavailable - ' +
                            new Date())
                    .appendTo('#fileupload');
            });
        }
    } else {
        $('#fileupload').fileupload('option', {
            //maxFileSize: 5000000,
            maxFileSize: 1048576,
            //acceptFileTypes: /(\.|\/)(gif|jpe?g|png|psd)$/i,
            acceptFileTypes: /(\.|\/)(doc|docx|gif|jpg|jpeg|pdf|png|psd|tif|tiff)$/i,
            singleFileUploads: true,
            sequentialUploads: true,
            autoUpload: true,
                    });

        var upfiles = "";
        $('#fileupload')
        //.bind('fileuploaddrop', function (e, data) {$.each(data.files, function (index, file) {alert('Added file: ' + file.name);});})
        //.bind('fileuploaddrop', function (e, data) {$.each(data.files, function (index, file) { upfiles += file.name + ",";});})
        .bind('fileuploaddone', function (e, data) {$.each(data.files, function (index, file) { upfiles += file.name + ",";});})
        .bind('fileuploadchange', function (e, data) {/* ... */})

        //fail: function (e, data) {data.submit();}
        //.fileupload({fail: function (e, data) {alert('FAIL');}});
        ;

       $('#fileupload')
        .bind('fileuploadstop', function (e, data) {
           //window.location.href = 'http://hiphopsmurf.com';
             $('#multimages', top.document).val(upfiles);
             parent.document.forms["multi_image"].submit();
             //parent.tb_remove();
        });

    }

});

我在Java脚本中度过了一个星期,所以在任何帮助下都会感激不尽。

1 个答案:

答案 0 :(得分:0)

通常,当您收到“方法未定义”错误时使用JavaScript / jQuery时,选择器会出现问题。

我会使用jQuery选择器来提交表单。尝试用以下方法替换问题:

$('#multi_image').submit();

(假设您的表单的id属性为“multi_image”)。