add loading

This commit is contained in:
solehudin5699
2022-02-28 00:48:44 +07:00
parent 357c590179
commit f08dac614e
+9 -1
View File
@@ -271,6 +271,9 @@
const formData = new FormData(); const formData = new FormData();
formData.append('image', imageFile); formData.append('image', imageFile);
btnSubmit.innerHTML = 'Loading...';
btnSubmit.setAttribute('disabled', true);
fetch('https://img-resize-xxx.herokuapp.com/', { fetch('https://img-resize-xxx.herokuapp.com/', {
method: 'POST', method: 'POST',
headers: {}, headers: {},
@@ -283,8 +286,13 @@
: `?quality=${qualityValue}&width=${widthValue}&height=${heightValue}`; : `?quality=${qualityValue}&width=${widthValue}&height=${heightValue}`;
anchorDonwload.setAttribute('href', result.urlImage + params); anchorDonwload.setAttribute('href', result.urlImage + params);
anchorDonwload.click(); anchorDonwload.click();
btnSubmit.innerHTM = 'Submit & Download';
btnSubmit.removeAttribute('disabled');
}) })
.catch((err) => console.log(err)); .catch((err) => {
btnSubmit.innerHTM = 'Submit & Download';
btnSubmit.removeAttribute('disabled');
});
}); });
</script> </script>
</html> </html>