-1
How to pass the PDF header through Javascript/jQuery?
I need to print a page, IE, when the user accesses it, it already sends the PDF header and sends it to download. How to do this by JS?
-1
How to pass the PDF header through Javascript/jQuery?
I need to print a page, IE, when the user accesses it, it already sends the PDF header and sends it to download. How to do this by JS?
1
To syntax to send a request header with jQuery would be:
$.ajax({
url: "/path/to/file.ext",
beforeSend: function( xhr ) {
xhr.setRequestHeader( 'Content-type', 'application/pdf' );
}
}).done( function( response ) {
// Dom something
})
However, unless mistaken, this will not have the intended result as 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’ve never seen any practical application, but I imagine sending that Request Header would allow the receiving application to work with the raw data ("raw data") of the request.
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.