3

我在 jquery 选项卡中使用 uploadify 插件,效果很好。上传完成后,在uploadify中,我正在发送电子邮件:

 $('#file_upload').uploadify({
                'fileTypeDesc': 'Image Files',
                'fileTypeExts': '*.gif; *.jpg',
                'swf': 'Scripts/Uploadify/uploadify.swf',
                'uploader': 'FileUploadHandler.ashx',
                'cancelImg': 'Scripts/Uploadify/uploadify-cancel.png',
                'buttonText': 'Browse',
                'onQueueComplete': function (queueData) {
                senEmail();
                }
            });

我的sendEmail功能在Ready function以下页面中:

var senEmail = function() {
                var notes = $("#<%=txtMessage.UniqueID%>");

                var msgbox = $("#cerror");
                $("#cerror").hide();
                $.ajax({
                    type: "POST",
                    url: "ContactMe.aspx/SendEmail",
                    data: "{'message': '" + notes.val() + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",

                    success: function (msg) {
                        if (msg.d == 'Sent') {
            var $tabs = $('#tabs').tabs(); // declare the tabs
            $tabs.tabs("url", 5, "/ContactConfirmation.aspx"); // change the URL of the selected tab
            $tabs.tabs("select", 5 + 1); // refresh the tab content
alert("masTEST3");
            $tabs.tabs("select", 5 ); // refresh the tab content
alert("endTEST");
                        }
                        else {
                            $("#cerror").show();
                            msgbox.html(msg.d);
                        }
                    }

                });
            };

现在上面的工作正常,就像发送电子邮件一样,但是当我将用户转发到确认页面时,我收到 jquery 错误:Object Expected并且不会转发到同一选项卡上的下一页(这适用于其他页面)。

感谢你的帮助。

编辑:::

这是 IE9 错误:

SCRIPT5007: Object expected 
jquery-1.8.3.min.js, line 2 character 24275

并且调试器在这一行:

return!t||t!==!0&&e.getAttribute("classid")===t}})
4

2 回答 2

3

找到解决方案以防其他人遇到同样的问题:

当标签更改/重新加载时,我不得不销毁上载对象所以在发送电子邮件之前我要做的就是这样的信息:

$("#file_upload").uploadify("destroy");
于 2012-12-20T11:21:10.700 回答
1

我已经解决了这个问题。

打电话

$("#file_upload").uploadify("destroy");

之后onUploadComplete确实有效。但是,如果您在不上传文件的情况下单击其他任何内容,它会使我项目中的所有 javascript 崩溃。所以我开始使用

$("#file_upload").uploadify("destroy"); 

在导致这个新错误出现的几个地方(关于具有nullundefined对象的设置)。我认为它是因为当我无法调用时,我试图调用破坏。无论哪种方式,这种方式也行不通。

所以我打开uploadify.js并决定在uploadify运行destroy时禁用其中一些选项。

在 uploadify.js 中找到destroy function并注释掉

    var $this        = $(this),
    swfuploadify = $this.data('uploadify');
    //settings     = swfuploadify.settings;

现在取消注释下面this使用的任何内容,settings例如:

/*/ 
    // Destroy the queue
    if (settings.defaultQueue) {
        $('#' + settings.queueID).remove();
    }

    // Reload the original DOM element
    $('#' + settings.id).replaceWith(swfuploadify.original);

    // Call the user-defined event handler
    if (settings.onDestroy) settings.onDestroy.call(this);
/*/

这将起作用。而且您仍然可以上传图片和所有内容。唯一的失败是你失去了这些项目的选择。在我的情况下,我一次只上传一张照片,所以这对我有用。你仍然必须使用

$("#file_upload").uploadify("destroy"); 

在你运行任何其他 javascript 之前div。因此,除了 uploadify 按钮之外,您拥有的任何选项卡或按钮都需要在按下这些按钮时销毁 uploadify。它必须是点击后的第一个动作。

于 2013-03-02T07:09:13.657 回答