aboutsummaryrefslogtreecommitdiffstats
path: root/src/public
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-02-11 11:30:40 -0600
committerMatt Strapp <matt@mattstrapp.net>2022-02-11 11:30:40 -0600
commite9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f (patch)
tree301a68cd34c73ce5ea2d158e4a4e463d183d0736 /src/public
parentDo a bunch of random things (still no feature parity) (diff)
downloadee4511w-web-e9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f.tar
ee4511w-web-e9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f.tar.gz
ee4511w-web-e9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f.tar.bz2
ee4511w-web-e9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f.tar.lz
ee4511w-web-e9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f.tar.xz
ee4511w-web-e9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f.tar.zst
ee4511w-web-e9cc00f8947d3aea0f802a8b8d7f2e406c3fcb1f.zip
Finish upload API endpoint
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'src/public')
-rw-r--r--src/public/js/form.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/public/js/form.js b/src/public/js/form.js
index cfa80fd..7085422 100644
--- a/src/public/js/form.js
+++ b/src/public/js/form.js
@@ -1,17 +1,18 @@
+// File submit AJAX request
document.getElementById('upload').onsubmit = function () {
- var data = new FormData(document.getElementById('upload'));
- var xhr = new XMLHttpRequest();
- xhr.open('POST', '/api/upload');
- xhr.send(data);
+ let xhr = new XMLHttpRequest();
+ xhr.open('POST', '/api/v1/upload');
+ let formData = new FormData(this);
+ xhr.send(formData);
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';
+ if (xhr.readyState === 4) {
+ let response = JSON.parse(xhr.responseText);
+ if (xhr.status === 200) {
+ console.log(response);
} else {
- document.getElementById('error').style.display = 'block';
+ console.log(response.error);
}
}
};
return false;
-};
+}; \ No newline at end of file