Hi. I'm using this plugin for jQuery to download a PDF via AJAX. Here's the code that fetches the PDF from ASP.NET Web API:
fetchFile: function (id) {
return new Promise(function (resolve, reject) {
$.ajax({
async: true,
dataType: "native", // Uses the jquery-ajax-native plugin for blobs.
type: "POST",
url: `https://someapp.org/api/files/file/fetch/${id}`,
xhrFields: { // Uses the jquery-ajax-native plugin for blobs.
responseType: "blob"
},
cache: false
}).done(function (data) {
return resolve(data);
}).fail(function (xhr, status, error) {
const errorObj = new Error(xhr.responseText || error);
return reject(errorObj);
});
});
}
I would like to feed the BLOB data returned by the fetchPdf function to set the PDFViewer's data. Is this possible? Maybe PDFViewer can fetch via AJAX directly. Any examples?
Thank you.