xmlhttp.onreadystatechange = function()

in code/app/static/main.js [175:195]


    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == XMLHttpRequest.DONE) {   // XMLHttpRequest.DONE == 4
           if (xmlhttp.status == 201) {
               // Waiting on Cloud Function to modify the images. 
               sendAlert("Processing image!");  
               setTimeout(listImages, 2000);
           }
           else if (xmlhttp.status == 500) {
            let msg = JSON.parse(xmlhttp.response);
            if (msg.error.includes("invalid image type")) {
                sendError(msg.error);
            } else {
                sendError(msg.error);
            }
           }
           else {
               alert('something else other than 201 was returned');
               console.log(xmlhttp.status);
           }
        }
    };