【问题标题】:Javascript stops running with no error messageJavascript 停止运行,没有错误消息
【发布时间】:2011-02-01 22:18:38
【问题描述】:

使用 Uploadify 和 JGrowl 组合:

<link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/jgrowl.css" />
<script type="text/javascript" src="js/jquery1.4.4.js"></script>
<script type="text/javascript" src="js/jgrowl.js"></script>
<link rel="stylesheet" type="text/css" href="css/artworkDesigner.css" />  
<link href="js/uploadify-2.1.4/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/uploadify-2.1.4/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/uploadify-2.1.4/swfobject.js"></script>
<script type="text/javascript" src="js/uploadify-2.1.4/jquery.uploadify.v2.1.4.min.js">/script>

<script type="text/javascript">    
    // <![CDATA[    
    var uploadType = "art";    
    var templateID = "42scs";

    $(document).ready(function() {

        $('#fileInput').uploadify({

            'uploader': 'js/uploadify-2.1.4/uploadify.swf',    
            'script': 'js/uploadify-2.1.4/UploadHandler.ashx',    
            'cancelImg': 'js/uploadify-2.1.4/cancel.png',    
            'scriptData': { 'type': uploadType, 'templateID': templateID },    
            'auto': true,    
            'multi': true,    
            'fileDesc': 'Image Files',    
            'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',    
            'queueSizeLimit': 90,    
            'sizeLimit': 4000000,    
            'buttonText': 'Choose Images',    
            'folder': '/uploads/test',    
            'onComplete': function(event, ID, fileObj, response, data) {

                if (response != "1") {

                    alert(response);   // ALERTS 'ERROR TEXT' which is expected

                    // DOESNT RUN THIS LINE:, AND REST OF SCRIPT SEEMS TO FREEZE 
                    $.jGrowl("<strong>Error!</strong><br />" + response, { sticky: true });
                    alert("flag"); // THIS IS NOT RUNNING

                } else {

                    alert(fileObj.name + "\n" + fileObj.filePath + "\n" + ID + "\n");
                    alert(response);

                }

            }

        });

    });

    // ]]></script>

这个脚本可以正常工作,当 templateID 设置为实数(末尾没有字符串故意抛出错误),但是当在42scs 中传递无效字符串时,如上面的代码所示,脚本提醒

“一些错误文字”

当服务器端抛出异常时,哪个是正确的返回值。然后脚本停止做任何其他事情,当它打算抛出 Jgrowl 错误时。有什么想法为什么没有发生?

我在另一个页面上使用完全相同的 Jgrowl,它工作正常。

【问题讨论】:

  • 您是否尝试过使用调试器单步执行代码?另外,这在哪些浏览器上不起作用(全部?)?另外,您是否尝试过(单独)运行$.jGrowl 来确定它是否完全有效,而不是在您的特定呼叫中?
  • 已修复,有 2 个对 jquery 的引用是我从uploadify 中盲目复制和粘贴的
  • 我认为 // &lt;![CDATA[ 不需要,因为 Mosaic 0.1 alpha :)
  • @Sime,谢谢,已删除!自带脚本

标签: javascript jquery uploadify jgrowl


【解决方案1】:

对 Jquery 库的双重引用会发生冲突:

<script type="text/javascript" src="js/jquery1.4.4.js"></script>
<script type="text/javascript" src="js/uploadify-2.1.4/jquery-1.4.2.min.js"></script>

【讨论】:

    猜你喜欢
    • 2013-06-09
    • 2018-03-22
    • 1970-01-01
    • 2020-05-07
    • 1970-01-01
    • 2015-06-28
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    相关资源
    最近更新 更多