From 5ab908d2553c24d942ed186566c7072b412fd2fc Mon Sep 17 00:00:00 2001 From: wiecktobi <39270895+wiecktobi@users.noreply.github.com> Date: Fri, 8 Jun 2018 17:31:10 +0200 Subject: [PATCH] Clickhandler --- js/contentloader.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/contentloader.js b/js/contentloader.js index c019e83..a6ce3fb 100644 --- a/js/contentloader.js +++ b/js/contentloader.js @@ -1,6 +1,7 @@ window.addEventListener('load', async () => { console.log("Seite geladen"); getNewUniqueLink(); + document.getElementById('create').addEventListener('click' , async (event) => createEntry()); }) async function getNewUniqueLink() { @@ -15,3 +16,18 @@ async function getNewUniqueLink() { } } +async function createEntry() { + event.preventDefault() + const formData = new formData(document.getElementById('create-form')); + + try { + const response = await fetch('php/login.php', { + method: 'post', + body: formData + }); + const jsonData = await response.json(); + + } catch (e) { + console.log("Fehler"); + } +}