From 0fbc317e926b5d80363979ee51a4e3c930014efd Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Fri, 11 Feb 2022 00:11:52 -0600 Subject: Do a bunch of random things (still no feature parity) sadge Signed-off-by: Matt Strapp --- src/public/js/form.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/public/js/form.js (limited to 'src/public/js/form.js') diff --git a/src/public/js/form.js b/src/public/js/form.js new file mode 100644 index 0000000..cfa80fd --- /dev/null +++ b/src/public/js/form.js @@ -0,0 +1,17 @@ +document.getElementById('upload').onsubmit = function () { + var data = new FormData(document.getElementById('upload')); + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/api/upload'); + xhr.send(data); + xhr.onreadystatechange = function () { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response.success) { + document.getElementById('success').style.display = 'block'; + } else { + document.getElementById('error').style.display = 'block'; + } + } + }; + return false; +}; -- cgit v1.2.3