Using compile Uploadify and 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">
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);
$.jGrowl("<strong>Error!</strong><br />" + response, { sticky: true });
alert("flag");
} 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 line at the end to purposefully throw an error), but when an 42scsinvalid string is passed in , as shown in the above code, warning script
"Some error text"
What is the correct return value when an exception is thrown on the server side. Then the script just stops doing anything else when it is intended to throw a Jgrowl error. Any ideas why this is not happening?
I use Jgrowl exactly the same on another page, and it works great.
source
share