使用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完全一样,并且工作正常。
答案 0 :(得分:3)
对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>