1

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

它给了我“未捕获的类型错误:无法调用未定义的方法”提交“在这行:

$('#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 脚本有一周的兴趣,因此将不胜感激。

4

1 回答 1

0

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

我会使用 jQuery 选择器来提交表单。尝试用这个替换问题行:

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

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

于 2013-01-06T15:38:11.890 回答