日期:2014-05-16  浏览次数:20343 次

Ajax js 拼接上传下载附件的链接 按钮
//遍历该条信息的附件

   $(".attachmentListTd").empty();
    $(data.listAttachment).each(function(i){
         $(".attachmentListTd").append("<a href=\"download.action?storeName="+data.listAttachment[i].storeName+"&fileName="+ data.listAttachment[i].encodedRealName  +"\">"+data.listAttachment[i].realName+"</a>");
         //$(".attachmentListTd").append("<input name=\"delAttBut\" type=\"button\" class=\"button1\" value=\"删  除\" onclick=\"javascript:deleteAttach("+data.listAttachment[i].id+","+data.cInfoJson.id +");\"/>");
            $(".attachmentListTd").append("<input name=\"delAttBut\" type=\"button\" class=\"button1\" value=\"删  除\" onclick=\"javascript:deleteAttach("+"'"+data.listAttachment[i].id+"'"+","+"'"+cId+"'"+");\"/>");
        $(".attachmentListTd").append("<br/>");
   });

?

? 注释句: //$(".attachmentListTd").append("<input name=\"delAttBut\" type=\"button\" class=\"button1\" value=\"删? 除\" onclick=\"javascript:deleteAttach("+data.listAttachment[i].id+","+data.cInfoJson.id +");\"/>");

?

会报缺少“)” 的错误

?

在方法的的参数加上单引号解决

deleteAttach("+"'"+data.listAttachment[i].id+"'"+","+"'"+cId+"'"+");