Created
November 26, 2024 19:23
-
-
Save Cosmologist/6f56fd1f60ad57e0bb6c45ccbacecb10 to your computer and use it in GitHub Desktop.
JavaScript: How to display binary data like pdf (ie from XmlHttpRequest response) in the browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This required xhr.responseType="blob" | |
window.open(URL.createObjectURL(new Blob([xhr.response], {type: xhr.getResponseHeader('content-type')}))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment