Ajax requests backend, and the backend returns binary data. How should JS be parsed?

background code snippet:

UtilHttp.streamContentToBrowser(response, UtilObject.getBytes(list), "application/octet-stream");

background list:

clipboard.png

listbyte[],ioJS
Ajax:


dataType: "text":

clipboard.png

...

XMLHttpRequest


byteArray: list

clipboard.png


returns the data as buffer with the native XMLHttpRequest, setting


the backend is jokingly identified, and the binary stream may be text, the video may be how to parse the picture.


returns data like java.util ? Is it dead when you go back backstage? (well, you can press the backstage to rub it on the ground. )


you can get the file directly without using the ajax call in the previous paragraph
or use the Blob object in the previous paragraph

ask this question in the previous paragraph


(the type you received is not text)

  • stream returns buffer, not Array
    , so the front end receives ArrayBuffer
    instead of a normal array
  • convert ArrayBuffer to string toString,
    JSON.parse to json object, which should be the list data you want
Menu