Dateien nach "public" hochladen
This commit is contained in:
29
public/script.js
Normal file
29
public/script.js
Normal file
@@ -0,0 +1,29 @@
|
||||
document.getElementById('wishForm').addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const category = document.getElementById('category').value;
|
||||
const link = document.getElementById('link').value;
|
||||
const title = document.getElementById('title').value;
|
||||
|
||||
const responseMessage = document.getElementById('responseMessage');
|
||||
|
||||
// Senden des Wunsches an den Telegram-Bot (API-Endpunkt anpassen)
|
||||
const response = await fetch('/api/sendWish', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ category, link, title })
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
responseMessage.textContent = 'Dein Wunsch wurde gesendet!';
|
||||
responseMessage.style.color = 'green';
|
||||
} else {
|
||||
responseMessage.textContent = 'Ein Fehler ist aufgetreten. Bitte versuche es erneut.';
|
||||
responseMessage.style.color = 'red';
|
||||
}
|
||||
|
||||
// Formular zurücksetzen
|
||||
event.target.reset();
|
||||
});
|
||||
Reference in New Issue
Block a user