开发者

Javascript stops running with no error message

开发者 https://www.devze.com 2023-02-07 17:36 出处:网络
Using an Uploadify and JGrowl combo: <link rel=\"stylesheet\" type=\"text/css\" href=\"css/default.css\" /><link rel=\"stylesheet\" type=\"text/css\" href=\"css/jgrowl.css\" />

Using an Uploadify and JGrowl combo:

<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"&g开发者_StackOverflowt;</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>

This script works fine, when templateID is set to a real number (without a string at the end to purposefully throw an error), but when an invalid string is passed in 42scs as shown in the code above, the script alerts

"Some error text"

Which is the correct return value when an exception is thrown server side. Then the script just stops doing anything else, when it is meant to throw the Jgrowl error. Any ideas why this isn't happening?

I'm using Jgrowl exactly the same on another page and it works fine.


Double reference to Jquery library will conflict:

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号