uploadify 返回值(回调函数)总结:
$(function() { $('#file_upload').uploadify({ 'formData' : { 'timestamp' : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>' }, 'swf' : './uploadify.swf', 'uploader' : './uploadify.php', //'uploader' : 'http://s.v9.com/getpic/upload.php', 'debug':true, 'scriptData': { 'key': '123' }, 'multi' : true, 'onComplete' : function(event, ID, fileObj, response, data) { //alert('There are ' + data.fileCount + ' files remaining in the queue.'); alert('qerew'); }, 'onUploadSuccess':function(file,data,response){ alert('123'); } }); });
注意:第17,18行,这两行就是接收返回值的,返回值在data里面
使用示例代码:
<script> $('#file_upload').uploadify({ 'swf' : '/Public/js/uploadify.swf', 'uploader' : "{:U('Users/avatar')}", 'buttonText' : '上传头像', 'onUploadSuccess' : function(file,data,response) { var obj = eval('('+data+')'); if(obj.status == 1){ $('#avatar').attr('src',obj.result); $('#avatar_input').val(obj.result); } else{ alert(obj.result); return false; } } }); </script>
转载请注明:苏demo的别样人生 » uploadify 返回值(回调函数)总结