You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I expect the response to be a binary blob file (actual response Content-Type: application/pdf), and am able to make it work with this code (where showFile handles processing and downloading the returned blob/file):
canAjax({
url: assembleUrl,
data: assembleData,
type: 'post',
contentType: 'application/x-www-form-urlencoded',
dataType: null,
xhrFields: {
responseType: 'blob' // pdf file
}
}).then((xhrObj) => {
// blob file is on xhr.response
showFile(xhrObj.response)
})
This works despite xhrObj.responseText showing:
responseText: [Exception: DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest':
The value is only accessible if the object's 'responseType' is '' or 'text' (was 'blob').
This code/switch statement should be updated to handle binary file response types, probably just returning xhr.response instead of the whole object:
I have a use case where I expect the response to be a binary blob file (actual response
Content-Type: application/pdf
), and am able to make it work with this code (whereshowFile
handles processing and downloading the returned blob/file):This works despite
xhrObj.responseText
showing:This code/switch statement should be updated to handle binary file response types, probably just returning
xhr.response
instead of the whole object:can-ajax/can-ajax.js
Lines 112 to 114 in c4e4c26
The text was updated successfully, but these errors were encountered: