From f08dac614e2d8bafe7121621f7623a4f46e72cf9 Mon Sep 17 00:00:00 2001 From: solehudin5699 Date: Mon, 28 Feb 2022 00:48:44 +0700 Subject: [PATCH] add loading --- public/index.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 571a60a..62c2210 100644 --- a/public/index.html +++ b/public/index.html @@ -271,6 +271,9 @@ const formData = new FormData(); formData.append('image', imageFile); + btnSubmit.innerHTML = 'Loading...'; + btnSubmit.setAttribute('disabled', true); + fetch('https://img-resize-xxx.herokuapp.com/', { method: 'POST', headers: {}, @@ -283,8 +286,13 @@ : `?quality=${qualityValue}&width=${widthValue}&height=${heightValue}`; anchorDonwload.setAttribute('href', result.urlImage + params); anchorDonwload.click(); + btnSubmit.innerHTM = 'Submit & Download'; + btnSubmit.removeAttribute('disabled'); }) - .catch((err) => console.log(err)); + .catch((err) => { + btnSubmit.innerHTM = 'Submit & Download'; + btnSubmit.removeAttribute('disabled'); + }); });