Första incheckningen. Protyp för PWA för att skapa todos
This commit is contained in:
31
public/app.js
Normal file
31
public/app.js
Normal file
@@ -0,0 +1,31 @@
|
||||
document.getElementById('taskForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Get form values
|
||||
const subject = document.getElementById('subject').value;
|
||||
const description = document.getElementById('description').value;
|
||||
const deadline = document.getElementById('deadline').value;
|
||||
|
||||
// Structure data for Org mode
|
||||
const taskData = {
|
||||
subject,
|
||||
description,
|
||||
deadline
|
||||
};
|
||||
|
||||
// Send data to backend using fetch
|
||||
fetch('/add-task', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(taskData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
document.getElementById('responseMessage').textContent = data.message;
|
||||
})
|
||||
.catch(error => {
|
||||
document.getElementById('responseMessage').textContent = "Error saving task!";
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user