Programming Tips - javaScript: receive image with Ajax

Date: 2018dec15 Language: javaScript Q. javaScript: receive image with Ajax A. Don't use jQuery, use raw XMLHttpRequest like this
const oReq = new XMLHttpRequest(); oReq.open('GET', '/myfile.png', true); oReq.responseType = 'blob'; oReq.onload = function(oEvent) { const url = URL.createObjectURL(oReq.response); myImage.src = url; }; oReq.send();
Based on https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data