Ayesha Fathima

Ayesha Fathima

  • NA
  • 184
  • 30.1k

show attachments in html table from servlet url

Feb 3 2018 3:40 AM
Hi ,
I have multiple attachments consist of file name and base64 content for each attachment from servlet URL,how can i set all the attachments in HTML table.After clicking on filename i should open that attachment.
How can i do that by using javascript or jquery only.
 
Here what i have tried
  1.             $.cordys.ajax({  
  2.                 method: "Getattachmentdetails",  
  3.                 namespace: "http://schemas.cordys.com/IMSPackage",  
  4.                 parameters: {  
  5.                     emailid:mailidvalue  
  6.                 },  
  7.                 dataType: '* json',  
  8.                  success: function (result) {   
  9.                  output=result;  
  10.                  bodycontent=output["data"]["body"];  
  11.                  for(var i=0;i<output["data"]["tuple"].length;i++)  
  12.                  {  
  13.                  attname=output["data"]["tuple"][i]["name"];  
  14.                  base64value=output["data"]["tuple"][i]["base64"];  
  15.                  }  
  16.            //$('#mailcontent').show();  
  17. //document.getElementById("mailcontent").value = bodycontent;  
  18.           attachmenttable = $('#attachmenttable').DataTable({  
  19.                 columnDefs: [{  
  20.                     orderable: false,  
  21.                     className: 'select-checkbox',  
  22.                     defaultContent: "",  
  23.                     targets: 0,  
  24.                  visible: false  
  25.                 }, {  
  26.                     data: attname,  
  27.                     defaultContent: "",  
  28.                     targets: 1,  
  29.                     visible: true  
  30.                 },   
  31.              {  
  32.                     data: "",  
  33.                     defaultContent: "",  
  34.                     targets: 2,  
  35.                  visible: true  
  36.                 }, {  
  37.                     data: base64value,  
  38.                     defaultContent: "",  
  39.                     targets: 3,  
  40.                  visible: true  
  41.                 }],  
  42.                 select: {  
  43.                     style: 'single',  
  44.                     selector: 'td:first-child'  
  45.                 },  
  46.           
  47.                 order: [  
  48.                     [2, 'asc']  
  49.                 ],  
  50.                 "searching"false,  
  51.              "retrieve"true,  
  52.                 "lengthChange"false  
  53.             });   
  54.                       },  
  55.                 error: function(err){  
  56.                     console.log(err);  
  57.                 }  
  58.                 });  
  59.         }  
 

Answers (2)