gooUploader 如何从服务器取数据

来源:互联网 发布:ug8.0编程免费视频教程 编辑:程序博客网 时间:2024/04/28 19:50

在GooUploader.js里有一段

this.$swfUpload.uploadSuccess=function(file,msg){
        var id=file.id;
        inthis.$fileList[id].span.html("100%");
        var li=inthis.$content.children("#"+id);
        li.children(".op_no").css("display","none");
        li.children(".op_ok").css("display","block");
     
    };

 

其中msg就是从服务器返回的数据。只要加上自己的处理函数就可以处理,如:

 this.$swfUpload.uploadSuccess=function(file,msg){
var id=file.id;
inthis.$fileList[id].span.html("100%");
var li=inthis.$content.children("#"+id);
li.children(".op_no").css("display","none");
li.children(".op_ok").css("display","block");
var callback=property.upload_complete;
callback(msg);

};

 

其中property.upload_complete为

var property={
       width:400,
       height:90,
       multiple:false,
       file_types_description: "资源文件",
          btn_add_text:"添加",
       btn_up_text:"上传",
       btn_cancel_text:"放弃",
       btn_clean_text:"清空",
       op_del_text:"单项删除",
       op_up_text:"单项上传",
       op_fail_text:"上传失败",
       op_ok_text:"上传成功",
       op_no_text:"取消上传",
       upload_url:"/admins/uploadResource.action",
       flash_url:"/codebase/swfupload.swf",
       upload_complete:upComplete
      };

的一个参数。

 

我的upComplete函数如下:

 function upComplete(msg){
    var strArray=msg.split(':');
     $("#upload_resource").remove();
     var upload_resource=$("<div style='color:blue;'> 文件:"+strArray[1]+"以上传!<input type='hidden' id='rid' value="+strArray[0]+"/><input type='button' onclick='deleteFile();' value='删除文件'/></div>");
     $("#upload_resource_td").append(upload_resource);
     
    }
   

服务器返回的数据写法如下:

 ServletActionContext.getResponse().getWriter().println(resource.getId()+":"+resource.getFileName());

 

ok完成!