internetprogrammierung/js/contentloader.js

35 lines
967 B
JavaScript
Raw Normal View History

2018-05-26 14:33:15 +02:00
window.addEventListener('load', async () => {
console.log("Seite geladen");
//getNewUniqueLink();
document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
2018-05-26 14:33:15 +02:00
})
async function getNewUniqueLink() {
try {
var firstFetch = await fetch('php/generateLink.php');
var jsonFirstFetch = await firstFetch.json();
var content = document.getElementById('content');
content.innerHTML = `${jsonFirstFetch.html}`;
} catch (e) {
console.log("Server nicht erreichbar.");
}
}
2018-06-11 18:15:21 +02:00
//<!--Register-->
document.getElementById('btnCreate').addEventListener("click" , async (event) => {
const formData = new FormData(document.getElementById('create-form'));
try {
const response = await fetch('php/signup.php', {
2018-06-11 18:15:21 +02:00
method: 'post',
body: formData
});
2018-06-13 19:46:32 +02:00
const jsonData = await response.json();
console.log(jsonData);
2018-06-11 18:15:21 +02:00
} catch (e) {
console.log("Abschicken der Daten fehlerhaft!");
}
})