How to pass the PDF header via JavaScript / jQuery?
I need to print a page, that is, when the user accesses it, it already sends the PDF header and sends it to download. How to do this by JS?
How to pass the PDF header via JavaScript / jQuery?
I need to print a page, that is, when the user accesses it, it already sends the PDF header and sends it to download. How to do this by JS?
$.ajax({
url: "/path/to/file.ext",
beforeSend: function( xhr ) {
xhr.setRequestHeader( 'Content-type', 'application/pdf' );
}
}).done( function( response ) {
// Dom something
})
However, unless this is a mistake, this will not have the desired result because it is a Request Header , that is, it indicates to the receiving program, defined in the AJAX URL that a PDF request would be made , rather than a Response Header that tells the browser to treat that output as a PDF.
I have never seen any practical applications, but I imagine that sending this Request Header would allow the receiving application to work with the raw data / p>