I do this:

$.get('/BSS/clients/printBillsJson.action', $.extend({date: date}, filterData), function(response) { var blob=new Blob([response]); var link=document.createElement('a'); link.href=window.URL.createObjectURL(blob); link.download="Docs.pdf"; console.log("blob: ", blob); console.log("link: ", link); link.click(); }); 

p response header:

 Content-Disposition attachment;filename="docs.pdf" Content-Type application/pdf Date Wed, 23 Dec 2015 15:01:24 GMT Server Apache-Coyote/1.1 Transfer-Encoding chunked 

In chrome offers to save the file (and I would like it to open), the fox does not work at all. I always did this through links, but in this case it’s not convenient, tell me, please, where to dig?

  • use the PDF.js library - zhenyab
  • Can you try to remove the Content-Disposition header? - LinnTroll
  • And can you explain what's wrong with the link option? - LinnTroll
  • In the version with the link it is not very convenient to do this: $ .extend ({date: date}, filterData) - STepeR
  • Content-Disposition removed in struts, now Content-Disposition: inline - STepeR

1 answer 1

In the end, I did the same:

 var date = $('#billInvoicingDate').val(); // дата в нужном формате строкой var rows = $('#legalListTableBody .clientRow'); var dateStr = '&date=' + date; window.open('/BSS/clients/printBillsJson.action?struts.enableJSONValidation=true' + dateStr + '&' + $.param(filterData), 'Документы'); // filterData - объект, $.param корректно его записывает в URL 
  • PS via Jquery.GET upload files, alas, is not convenient. - STEPER