How to get and open the PDF browser with Jquery. GET
-
I'm doing
$.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(); });
puzzle:
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 the chrome, you're suggesting keeping the file. I've always done this through the references, but in this case it's not convenient, please tell me where to dig?
-
In the end, he 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