How to pass binary data from the server and on the server in js?

There is a file with the code that is on the server. Do I have to edit in the client browser.
How to transfer files from a tricky content(read, binary) without spoilage by means of JS?
Receive take the result variable from the js.
June 5th 19 at 21:47
2 answers
June 5th 19 at 21:49
June 5th 19 at 21:51
You can, for example, like this:
var xhr = new XMLHttpRequest();'GET', 'song.mp3', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function()
 var c = document.getElementById('canvas-view1');
 drawBuffer(c.width c.height c.getContext('2d'), buffer)

You can also translate the file to base64 and pass it as a string.

Find more questions by tags HTMLJavaScriptWeb Development